Merge JPG to PDF in Java

High-speed and cross-platform Java library for merging JPG to PDF files using Java code

Merge JPG to PDF using Aspose.Slides

Aspose.Slides for Java is a powerful Java library used to create, convert, merge, and manipulate presentations, PDFs, images, and other files. When you merge JPG to PDF, you are effectively combining JPG images to get a single PDF file.

Merge JPG to PDF in Java

Using Aspose.Slides for Java , you can merge JPG to PDF quickly with just a few lines of code

Java code for merging JPG to PDF

Presentation pres = new Presentation();
try {
    IPPImage image1 = pres.getImages().addImage(Files.readAllBytes("image1.jpg"));
    pres.getSlides().get_Item(0).getShapes().addPictureFrame(ShapeType.Rectangle, 0, 0, 100, 100, image1);

    IPPImage image2 = pres.getImages().addImage(Files.readAllBytes("image2.jpg"));
    pres.getSlides().get_Item(0).getShapes().addPictureFrame(ShapeType.Rectangle, 0, 200, 100, 100, image2);"pres.pdf", SaveFormat.Pdf);
} finally {
    if (pres != null) pres.dispose();

How to merge JPG to PDF in Java

  1. Install Aspose.Slides for Java. See Installation .

  2. Add the library as a reference in your project.

  3. Create an instance of the Presentation class.

  4. Load the JPG images you want to merge together as picture frames.

  5. Save the resulting PDF file.

Merge PDF Files Online

How to Merge PDF in Python

Merge other files

You can also combine files in other formats to get a single file