Convert Image to PDF in Java

If you need to generate a PDF from images, you have landed on the right page. Because this article provides an easy yet powerful method of converting images to PDF in Java. Not only this, the provided method takes care of the high-quality image to PDF conversion within no time. So let’s see how to perform image to PDF conversion in Java.

Java Library to Convert Image to PDF

To convert image to PDF, we will use Aspose.PDF for Java. It is a PDF manipulation library 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 library 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.12</version>
</dependency>

How to 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 image to PDF conversion in Java.

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.

Free Java Image to PDF Conversion

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

Explore Java PDF Library

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