Microsoft Publisher (PUB) files are used to create a variety of documents, including brochures, flyers, and newsletters. However, PUB files are not widely supported, and many applications cannot open them. In some cases, you may need to convert a PUB file to a PNG image. In this blog post, we will learn how to convert PUB to PNG in C#.
This article covers the following topics:
- C# API to Convert PUB to PNG
- Steps to Convert PUB to PNG
- Convert PUB to JPG
- Convert PUB to Image Online
- Free Learning Resources
C# API to Convert PUB to PNG
Converting a PUB to a PNG image comprises two steps. Firstly, we will use the Aspose.PUB for .NET API to load and render the PUB file into PDF format. After that, the pages of the PDF file will be converted into JPG images using the Aspose.PDF for .NET API.
Please download the DLLs of the APIs or install them using the following NuGet commands:
PM> Install-Package Aspose.Pdf
PM> Install-Package Aspose.PUB
How to Convert Publisher PUB File to PNG
We can easily convert a PUB file to a PNG image by following the steps below:
- Create a PUB parser and parse the PUB file.
- Convert a PUB to a PDF file stream.
- Loop through all the pages of the PDF document.
- Create a PNG device and process pages to save as PNG images.
Now, let’s see how to perform these steps in C# to convert a Publisher PUB file to a PNG.
Convert PUB to PNG using C#
We can easily convert PUB files into PNG images in C# by following the steps below:
- Create a PUB parser using the PubFactory.CreateParser().
- Convert a PUB to a PDF file using the ConvertToPdf() method.
- Load the PDF document using the Document class object.
- Loop through all the PDF pages.
- Create a PNG device using the PngDevice class object.
- Call the Process() method and save the converted PNG image.
The following code sample shows how to convert a PUB file to a PNG image in C#.
Get a Free API License
You can evaluate the APIs in their full capacity by requesting a free temporary license.
PUB to PNG Converter Online
Please try this free PUB to PNG Converter online app to convert publisher files to PNG images without installing any software or plugin.
PUB File to PNG – Learning Resources
Besides converting Publisher PUB files into PNG images, explore various other features of Aspose.PUB for .NET using the following resources:
Conclusion
In this article, we have learned how to programmatically convert PUB to PNG in C#. By following the steps outlined in this article, you can develop your own PUB to PNG converter application. In case of any ambiguity, please feel free to contact us on our free support forum.