วิธี Render XSL FO เป็นไฟล์ PDF โดยใช้ C++

ในบทช่วยสอนนี้ เราจะเรียนรู้วิธี เรนเดอร์ไฟล์ Xsl Fo เป็น PDF โดยใช้ C+* ไฟล์ Xsl Fo มีการจัดรูปแบบสไตล์ชีต XML ซึ่งใช้สร้างไฟล์ PDF ด้วยการเรียก API ง่ายๆ สองสามรายการใน C++ คุณลักษณะนี้ไม่จำเป็นต้องติดตั้ง Adobe Acrobat หรือแอปพลิเคชันใดๆ บนแพลตฟอร์ม Windows หรือ Linux

ขั้นตอนใน Render Xsl Fo เป็นไฟล์ PDF โดยใช้ C++

  1. ติดตั้งไลบรารี Aspose.Pdf for C++ จาก NuGet package manager
  2. เพิ่มการอ้างอิงไปยังเนมสเปซ Aspose::Pdf
  3. เริ่มต้นวัตถุของคลาส XslFoLoadOptions เพื่อโหลดไฟล์อินพุต
  4. โหลดไฟล์อินพุต Xsl Fo โดยใช้คลาส Document
  5. แปลงไฟล์ Xsl Fo เป็น PDF ด้วยวิธีการบันทึก

คุณสามารถ แปลง Xsl Fo เป็นไฟล์ PDF โดยใช้ C++ ด้วยโค้ดสองสามบรรทัด สามารถ สร้างไฟล์ Xsl Fo เป็น PDF โดยใช้ C++ ได้อย่างมีประสิทธิภาพด้วยวัตถุ XslFoLoadOptions

รหัสเพื่อ Render Xsl Fo เป็นไฟล์ PDF โดยใช้ C++

#pragma once
#include <iostream>
#include <system/smart_ptr.h>
#include <Aspose.PDF.Cpp/License.h>
#include <Aspose.PDF.Cpp/Document.h>
#include <Aspose.PDF.Cpp/XslFoLoadOptions.h>
using namespace System;
using namespace Aspose::Pdf;
class XSLFOEx {
public:
static void ConvertXslFo()
{
// Set the license for Aspose.PDF for CPP to create PDF from XSL FO file
SharedPtr<License> XSLFOtoPDFLicense = System::MakeObject<License>();
XSLFOtoPDFLicense->SetLicense(u"Aspose.PDF.NET.lic");
// Create an instance of the XslFoLoadOptions class
SharedPtr<XslFoLoadOptions> options = MakeObject<XslFoLoadOptions>();
// Load the input XSL FO file
SharedPtr<Document> InputXSLFODocument = MakeObject<Document>(u"InputXSLFODocument.fo", options);
// Save the XSL FO document as PDF file
InputXSLFODocument->Save(u"OutputPDFConvertedFromXSLFOFile.pdf");
}
};

ในหัวข้อที่แล้ว เราได้เรียนรู้เกี่ยวกับ วิธีอ่านบุ๊กมาร์กในไฟล์ PDF โดยใช้ C++ หัวข้อนี้ครอบคลุมวิธีใช้ C++ ส่งออก Xsl Fo เป็นไฟล์ PDF

 ไทย