In this tutorial, we will learn how to render Xsl Fo to PDF file using C++. The Xsl Fo file contains XML style sheet formatting which is used to generate a PDF file with a few simple API calls in C++. The feature does not need installation of Adobe Acrobat or any application on Windows or Linux platforms.
Steps to Render Xsl Fo to PDF File using C++
- Install the Aspose.Pdf for C++ library from NuGet package manager
- Add the reference to Aspose::Pdf namespace
- Initialize an object of XslFoLoadOptions class to load input file
- Load the input Xsl Fo file using the Document class
- Convert the Xsl Fo to PDF file with the Save method
You can convert Xsl Fo to PDF file using C++ with a couple of lines of code. It can generate Xsl Fo to PDF file using C++ efficiently with XslFoLoadOptions object.
Code to Render Xsl Fo to PDF File using 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"); | |
} | |
}; |
In the previous topic, we learned How to Read Bookmarks in PDF File using C++. This topic covers how using C++ export Xsl Fo to PDF file.