This tutorial will teach you how to convert Image to PDF in Java. Converting a document to PDF format is a simple process that requires only a few lines of code and no third-party software. Following the instructions below, you will be able to develop functionality to convert Image to PDF using Java.
Steps to Convert Image to PDF in Java
- Setup GroupDocs.Conversion for Java from the Maven repository into the application
- Initialize Converter class and load the input Image file
- Create an instance of the PdfConvertOptions class and define attributes for the output PDF document
- Save the PDF document to a disk with the help of the Convert method of the Converter class. Further, pass PdfConvertOptions instance and name of the output file
For implementing the Java convert Image to PDF capability, these are very simple and self-explanatory instructions that anyone may follow. Basic document conversion from JPG to PDF can be done using the points listed above. The PdfConvertOptions class, on the other hand, allows you to define a variety of parameters for the output PDF document.
Code to Convert Image to PDF in Java
For demonstration purposes, we have generated the aforementioned Java code to convert JPG to PDF feature. You can use this sample code in your project, along with the detailed instructions above, to perform document transformation. We’ve also created a PDF document from a JPG image, but you may convert any image file to a PDF document, including TIFF, TIF, JPEG, JPG, PNG, GIF, and BMP.
We have recently published an article on performing document conversion from Word to PDF in Java. If you want to have a look at it, you may visit how to convert Word to PDF in Java tutorial.