Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save groupdocs-com-kb/d9c61412ad1742eecd6f926187d4c0fa to your computer and use it in GitHub Desktop.
Save groupdocs-com-kb/d9c61412ad1742eecd6f926187d4c0fa to your computer and use it in GitHub Desktop.
How to Convert Image to PDF in Java. For more information, please follow link: https://kb.groupdocs.com/conversion/java/how-to-convert-image-to-pdf-in-java/
import com.groupdocs.conversion.Converter;
import com.groupdocs.conversion.licensing.License;
import com.groupdocs.conversion.options.convert.PdfConvertOptions;
public class ConvertImageToPdfInJava {
public static void main(String[] args) { // Main function to convert Image to PDF in Java
// Remove the watermark in output PDF document by adding license
License lic = new License();
lic.setLicense("GroupDocs.Conversion.lic");
// Load the source Image file for conversion to PDF
Converter converter = new Converter("sample.jpg");
// Set the convert options for PDF document
PdfConvertOptions options = new PdfConvertOptions();
// Convert and save the JPG in PDF format
converter.convert("converted.pdf", options);
System.out.println("Done");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment