Convert PUB Files | Aspose.PUB for C++
Overview to .pub conversion functionality via C++
This article shows how to convert PUB files to PDF in C++. It can be used to write C++ converter applications for PUB to PDF. Large Content Management Systems (CMS) convert editable files into read-only PDF documents using bulk operations that makes utilization of such convert applications.
Converting PUB files offers an alternative solution when you need to open or edit Microsoft Publisher files using different software. Let’s explore additional reasons to convert PUB files:
- Some software and devices do not support the PUB file format, which makes it necessary to convert the files in order to access and view them on various platforms.
- Converting PUB files to a universal format makes it easier to collaborate with individuals who do not have Microsoft Publisher, as it allows everyone to access and work on the files.
- Converting PUB files to formats such as PDF or XPS helps eliminate potential printing issues.
- By converting PUB files to a more standardized format, their long-term accessibility is ensured. This means you can still access your documents in the future, even if Microsoft Publisher becomes outdated.
You have several options for converting PUB files into different formats, including PDF, DOCX (Microsoft Word), HTML (web page format), or different image formats. The choice of format depends on your specific needs and the software or platform you plan to use. Here you can find information on how to convert .pub files with C++ APIs but if you’d better use an online solution without the need for coding, you can use cross-platform converters.
At present, the API doesn’t support the conversion of images in a PUB file to output PDF.
PUB to PDF in C++
Aspose.PUB for C++ lets you convert PUB to PDF in your C++ applications. PDF is a platform-independent document format, introduced by Adobe Acrobat, and can be opened on almost all computers without the need for Microsoft Publisher being installed.
The following steps and code snippet show how to convert PUB to PDF using C++.
Aspose.PUB for C++ supports converting multi-page PUB documents to PDF using the same lines of code given in this article.
The code snippet below demonstrates the usage of Aspose.PUB library for C++ to convert a Microsoft Publisher file to PDF format. Additionally, it initializes the library’s license object and sets the appropriate license for usage:
Create an instance of the Aspose::Pub::License class named license using the System::MakeObject method.
Set the license by calling the SetLicense method on the license object, passing the path to the license file (dataDir() + u"License\Aspose.PUB.C++.lic") as a parameter. This ensures that the library is properly licensed for usage.
Declare two System::String variables named filePub and filePdf, representing the paths to the
.pub
file and the desired output PDF file, respectively. To create the path use the dataDir() function.Create a shared pointer (System::SharedPtr) named parser of type IPubParser using the PubFactory::CreateParser() method, passing filePub as a parameter.
Create a shared pointer (System::SharedPtr) named document of type Document by calling the Parse() method on the parser object. The method reads and extracts the content of the
.pub
file, storing it in the document object for further processing.Use PubFactory::CreatePdfConverter() to create a PDF converter object, and then call the ConvertToPdf() method on the converter object, passing the document object and filePdf as parameters. This method converts the parsed
.pub
document to.pdf
and saves it to the specified output file.
Go to the product page to fully discover PUB to PDF conversion via C++