Microsoft Publisher Files are used for printing or publishing information. You can convert PUB) to JPG, PNG, or TIFF images programmatically using Java. In this article, you will learn how to convert the PUB file to different image formats:
- PUB to Image Conversion – Java API Installation
- Convert PUB to JPG Image Programmatically using Java
- Convert PUB to PNG Image Programmatically with Java
- PUB to TIFF Conversion Programmatically in Java
PUB to Image Conversion – Java APIs Installation
Aspose.PUB for Java API supports working with PUB files. You can render the PUB files to PDF and then utilize Aspose.PDF for Java API to convert the output PDF file to image formats like JPG, PNG, TIFF, etc. You can 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>20.8</version> </dependency> <dependency> <groupId>com.aspose</groupId> <artifactId>aspose-pdf</artifactId> <version>20.5</version> </dependency> </dependencies>
Convert PUB to JPG Image Programmatically using Java
You can convert a Microsoft Publisher (PUB) file to JPG image with the following steps:
- Load input PUB file.
- Convert PUB to PDF file with convertToPdf method.
- Get page dimensions from the PDF document.
- Specify the Resolution and dimensions of the output image.
- Save output JPG image using JpegDevice.
The code below explains how to convert PUB to JPG image using Java:
Convert PUB to PNG Image Programmatically with Java
You can convert a PUB file to PNG format image with the steps below:
- Load input PUB file with createParser() method.
- Convert PUB to PDF file.
- Specify width and height of output image.
- Finally, convert PUB to PNG image.
The following code shows how to convert PUB to PNG image with Java:
PUB to TIFF Conversion Programmatically in Java
You can convert PUB file to a TIFF image with the steps listed below:
- Firstly, load the input Publisher (PUB) file.
- Convert PUB to PDF file using convertToPdf() method.
- Specify properties for TIFF image using TiffSettings class.
- Finally, convert PUB to TIFF image with TiffDevice instance.
The following code demonstrates how to convert PUB to TIFF image programmatically using Java:
Get Free API License
You can evaluate the API in its full capacity by requesting a Free Temporary License.
In conclusion, you have learned how to convert Microsoft Publisher, PUB, files to different image formats like JPG, PNG, TIFF, etc, programmatically using Java. Moreover, you can learn about more features by visiting the Documentation of Aspose.PUB for Java API. Furthermore, please feel free to contact us via the Free Support Forum for any of your concerns.