Šioje pamokoje sužinosime, kaip pateikti Xsl Fo į PDF failą naudojant C++. Xsl Fo faile yra XML stiliaus lapo formatavimas, kuris naudojamas sugeneruoti PDF failą keliais paprastais API iškvietimais C++. Funkcijai nereikia įdiegti “Adobe Acrobat” ar jokios programos Windows ar Linux platformose.
Veiksmai, kaip pateikti Xsl Fo į PDF failą naudojant C++
- Įdiekite Aspose.Pdf for C++ biblioteką iš NuGet paketų tvarkyklės
- Pridėkite nuorodą į Aspose::Pdf vardų erdvę
- Norėdami įkelti įvesties failą, inicijuokite XslFoLoadOptions klasės objektą
- Įkelkite įvesties Xsl Fo failą naudodami klasę Dokumentas
- Konvertuokite Xsl Fo į PDF failą naudodami išsaugojimo metodą
Galite konvertuoti Xsl Fo į PDF failą naudodami C++ su keliomis kodo eilutėmis. Jis gali efektyviai generuoti Xsl Fo į PDF failą naudodamas C++ su XslFoLoadOptions objektu.
Kodas, skirtas Xsl Fo atvaizdavimui į PDF failą naudojant 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"); | |
} | |
}; |
Ankstesnėje temoje sužinojome Kaip skaityti žymes PDF faile naudojant C++. Šioje temoje aprašoma, kaip naudojant C++ eksportuoti Xsl Fo į PDF failą.