Microsoft Publisher files are used for publishing content on large scale. However, limited applications support this file format so you might need an image or thumbnail of the PUB file for a quick preview. You can convert PUB to PNG, JPEG, or TIF image programmatically using C#. Please check out the following use cases for details:
- PUB to Image Conversion – C# APIs Installation
- Convert PUB to PNG Image Programmatically with C#
- Convert PUB to JPEG Image Programmatically using C#
- PUB to TIF Image Conversion Programmatically with C#
- Get a Free API License
PUB to Image Conversion – C# APIs Installation
You can convert the PUB files to Image formats like PNG, JPEG, and TIF files. Basically, it is a two-step conversion where you need to convert PUB to PDF and then render it to image formats. Therefore, you need to install Aspose.PUB for .NET as well as Aspose.PDF for .NET API in your environment. You can download the DLL files from the New Releases section, or run the following installation commands to configure APIs from NuGet gallery:
PM> Install-Package Aspose.Pdf
PM> Install-Package Aspose.PUB
Convert PUB to PNG Image Programmatically with C#
You can convert a PUB file to PNG image with the following steps:
- Initialize the MemoryStream object to hold the PDF file.
- Convert PUB to PDF file with ConvertToPdf() method.
- Get page dimensions from the input PDF document.
- Create a PNG device using the PngDevice class object.
- Convert PUB to an output PNG image.
The code below explains how to convert PUB file to PNG image programmatically using C#:
Convert PUB to JPEG Image Programmatically using C#
Please follow the steps below for converting PUB file to JPEG format with C#:
- Declare MemoryStream class object.
- Parse input PUB file with Parse() method.
- Convert PUB to PDF file with IPdfConverter.ConvertToPdf() method.
- Create a Jpeg device with specified Width, Height, and Resolution.
- Convert the PUB file and save the output JPEG image.
The following code snippet shows how to convert PUB file to JPEG image programmatically using C#:
PUB to TIF Image Conversion Programmatically with C#
You can convert PUB file to TIF image format by following the steps below:
- Parse input PUB file with IPubParser.Parse() method.
- Convert PUB to PDF file using IPdfConverter interface.
- Create Resolution object.
- Initialize the TiffDevice class object.
- Convert the PUB file to the output TIF image.
The code below demonstrates how to convert PUB file to a TIF image programmatically using C#:
Get a Free API License
You can evaluate the APIs in their full capacity by requesting a free temporary license.
Conclusion
In this article, you have learned how to convert PUB files to PNG, JPEG, or TIF image formats programmatically using C# language. You may visit the Documentation for more details and write to us at Free Support Forum, in case of any queries.