Convert PUB to PNG, JPEG, or TIF Image using C#

PUB to PNG JPEG TIF Image

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

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:

  1. Initialize the MemoryStream object to hold the PDF file.
  2. Convert PUB to PDF file with ConvertToPdf() method.
  3. Get page dimensions from the input PDF document.
  4. Create a PNG device using the PngDevice class object.
  5. 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#:

  1. Declare MemoryStream class object.
  2. Parse input PUB file with Parse() method.
  3. Convert PUB to PDF file with IPdfConverter.ConvertToPdf() method.
  4. Create a Jpeg device with specified Width, Height, and Resolution.
  5. 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:

  1. Parse input PUB file with IPubParser.Parse() method.
  2. Convert PUB to PDF file using IPdfConverter interface.
  3. Create Resolution object.
  4. Initialize the TiffDevice class object.
  5. 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.

See Also

Convert PUB to PDF Programmatically in C#