Convert Image to PDF in Java

PDF is a widely used format for sharing and printing documents. You often prefer to convert the files to PDF format before sending them to others. In some cases, the images like PNG and JPG are also required to be converted to PDF documents. Therefore, in this article, you will learn how to convert an image to PDF format in Java. We will also demonstrate the conversion of multiple images to a PDF programmatically.

Java Image to PDF Converter API - Free Download

Aspose.PDF for Java is a PDF manipulation API that you can use to create, modify, and process PDF files. Furthermore, its high-quality converter lets you convert PDF and other documents seamlessly. You can either download the API or install it using the following Maven configurations.

Repository

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>https://releases.aspose.com/java/repo/</url>
</repository> 

Dependency

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

Convert an Image to PDF in Java

In this section, we’ll see how to convert an image to a PDF file in Java. This can be useful when you need to convert each image into a separate PDF file. The following are the steps to perform this operation.

The following code sample shows how to convert a PNG image to a PDF in Java.

Convert Multiple Images to a PDF in Java

The following are the steps to convert multiple images to a single PDF file in Java.

The following code sample shows the conversion of multiple images to a single PDF in Java.

Image to PDF Java Converter - Get a Free License

You can convert images to PDF without evaluation limitations by getting a free temporary license.

Java PDF API - Read More

You can explore more about Aspose.PDF for Java using documentation. In case you would have any queries, feel free to let us know via our forum.

Conclusion

In this article, you have learned how to convert an image to PDF format in Java. Also, you have seen how to convert multiple images to a single PDF programmatically. Thus, you can easily perform any kind of image-to-PDF conversion in your application.

See Also