Convert Publisher to PNG in Java | PUB to PNG Converter

Are you looking for a way to export your PUB files into PNG images without using Microsoft Publisher? Look no further! This blog post will guide you through the process of converting PUB to PNG using Java. Microsoft Publisher is a desktop publishing application that creates PUB files. A PUB file contains the layout, text, images, and formatting elements of the document. Converting Microsoft Publisher files into PNG images allows sharing your content in a widely supported image format. Let’s get started and learn how to convert Publisher to PNG in Java.

This article covers the following topics:

  1. Java API to Convert Publisher to PNG
  2. Convert PUB to PNG in Java
  3. Convert PUB to PNG Online
  4. Free Resources

Java API to Convert Publisher to PNG

The PUB to PNG conversion is a two-way process. First, we’ll use the Aspose.PUB for Java library to load the PUB file and render it as a PDF. Then, we’ll call upon Aspose.PDF for Java, a powerful toolkit for all things PDF. It will take the rendered PDF and convert each page into a clean PNG image.

Please download the JAR files for Aspose.PUB for Java and Aspose.PDF for Java API, or specify the following configurations to download the APIs from the Maven repository:

<repositories>
    <repository>
        <id>AsposeJavaAPI</id>
        <name>Aspose Java API</name>
        <url>http://repository.aspose.com/repo/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>com.aspose</groupId>
        <artifactId>aspose-pub</artifactId>
        <version>22.8</version>
    </dependency>

    <dependency>
        <groupId>com.aspose</groupId>
        <artifactId>aspose-pdf</artifactId>
        <version>24.5</version>
    </dependency>
</dependencies>

Convert Publisher to PNG in Java

Please follow the steps below to programmatically convert the Publisher PUB file to a PNG image in Java:

  1. Create a parser using PubFactory.createParser() method.
  2. Call the parse() method to process the PUB file.
  3. Create a memory stream to store the PDF file.
  4. Use the convertToPdf() method to transform the PUB file into a PDF and save it in the MemoryStream.
  5. Create a Document class object using the PDF stream.
  6. Get PDF file information using the PdfFileInfo.
  7. Loop through PDF pages and get their height and width, and set their resolution.
  8. Create a JpegDevice with the page’s height, width, and resolution.
  9. Finally, call the process() method to save the page as a PNG image.

The following code sample shows how to convert a Publisher PUB file to PNG in Java.

Convert PUB to PNG in Java

Convert PUB to PNG in Java.

Get a free temporary license to try the libraries without restrictions.

PUB to PNG Converter - Free Online

Alternatively, use this free online PUB to PNG Converter to convert Publisher files to PNG images without installing any software.

Publisher to PNG – Free Resources

In addition to converting Publisher files into PNG format, explore other features of these APIs using these resources:

Conclusion

In this article, we experienced how to convert Publisher PUB files into PNG format using Java. With the help of Aspose.PUB and Aspose.PDF for Java libraries, you can simplify the process. The steps outlined here allow you to effortlessly transform your publisher designs into high-quality PNG images.

Ready to give it a try? Download Aspose.PUB for Java and start converting your PUB files today! If you prefer an online solution, our free PUB to PNG Converter is always available. In case of any ambiguity, please feel free to contact us on our free support forum.

See Also