Convert GIF Images to PDF using Java

gif to pdf java

Being the software and hardware-independent format, PDF gives an outstanding user experience as compared to other document formats. The consistent layout of PDF makes it a universal format. Therefore, in various scenarios, the documents or images are converted to PDF before they are shared or exchanged. In this article, you will learn how to convert animated GIF images to PDF using Java. Particularly, we will convert each frame in a GIF to an image in a PDF file.

Java GIF to PDF Converter API

Aspose.Imaging for Java is designed to perform image processing operations from within your Java applications. The API lets you manipulate popular image formats seamlessly. Furthermore, its built-in converter API allows you to convert images from one format to another. Aspose.Imaging for Java can be downloaded as JAR or installed using the following Maven configurations.

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>http://repository.aspose.com/repo/</url>
</repository>
<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-imaging-java</artifactId>
    <version>20.12</version>
    <classifier>jdk16</classifier>
</dependency>

Convert GIF to PDF using Java

The following are the steps to convert a GIF image to PDF using Aspose.Imaging.

The following code sample shows how to convert a GIF to PDF using Java.

Animated GIF

Converted PDF

gif to pdf java

Convert Particular GIF Frame to PDF

You can also convert a particular frame or a range of frames in GIF to PDF. The following are the steps to perform this operation.

The following code sample shows how to convert particular frame(s) of a GIF to PDF using Java.

Set Page Size in GIF to PDF Conversion

Aspose.Imaging for Java also lets you specify the dimensions of the pages in the converted PDF document. The following are the steps to set the height and width of the pages in GIF to PDF conversion.

The following code sample shows how to set the page size in Java GIF to PDF conversion.

Java GIF to PDF – Set Document Info

The PDF format allows you to set the additional information about the document including author, subject, title, and keywords. You can also set these properties for the converted PDF document in GIF to PDF conversion. The following are the steps to set the document information of the PDF.

The following code sample shows how to set PDF document info in GIF to PDF conversion.

Get a Free API License

In case you want to try the API without evaluation limitations, you can get a free temporary license.

Conclusion

In this article, you have learned how to convert GIF images to PDF using Java. Furthermore, different options have been discussed to customize GIF to PDF conversion. You can explore more about the Java image processing API using documentation.

See Also