This brief tutorial explains how to convert PUB to PDF in C#. This contains the details from the initial step of setting up the environment, then the algorithm and a code snippet are presented to cover details related to the process to convert Publisher to PDF in C#. Moreover, you do not need to install any other tool to work with the source PUB files and write it as a PDF file.
Steps to Convert PUB to PDF using C#
- Configure Aspose.PUB library to work with PUB files
- Load the source publisher file using the CreateParser method
- Export the output file with the ConvertToPdf method
Here the step-by-step algorithm is explained to help you understand the process to export Publisher file to PDF in C#. The PubFactory class includes different overloaded methods to create parsers for PUB file from a file or a stream. Likewise, the IPdfConverter class is capable of converting the parsed PUB file to a PDF document.
Code to Convert PUB to PDF in C#
You can use this code snippet to convert Microsoft Publisher to PDF in C#. However, it can be modified to satisfy your requirements like choosing between loading the PUB file from a stream or using the file path string. In the final step, call the ConvertToPdf method to export the output PDF document while passing the file name.
This tutorial has covered the information on converting PUB file to PDF in C#. Whereas, if you want to render the PUB file to an image, please read the article on how to convert PUB to PNG in C#.