Convert Image to PDF in Java
Convert image files to PDF documents using Aspose.Slides for Java without Microsoft PowerPoint.
Convert Image to PDF using Java
To convert an image to PDF, add the source image to a Presentation and save the result as a PDF document.
Java code for converting Image into PDF
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
byte[] imageData = Files.readAllBytes(Paths.get("image.png"));
IPPImage presentationImage = presentation.getImages().addImage(imageData);
slide.getShapes().addPictureFrame(ShapeType.Rectangle, 0, 0, 720, 540, presentationImage);
presentation.save("image.pdf", SaveFormat.Pdf);
} finally {
presentation.dispose();
}Convert Image to PDF in Java
Aspose.Slides for Java
is a presentation processing API that can add image files to slides and save them as PDF documents.
You can load an image as an IPPImage, place it in a picture frame, and save the presentation with SaveFormat.Pdf.
How to convert Image to PDF using Aspose.Slides for Java API
These are the steps to convert Image to PDF in Java.
- Install Aspose.Slides for Java.
- Add a library reference (import the library) to your Java project.
- Load the source image as an
IPPImage. - Save the presentation with
SaveFormat.Pdf.
Built with Aspose.Slides
Convert Image to PDF Online
The free Aspose.Slides Conversion app is built with Aspose.Slides for Java, the same API as the code above. Open it and see what the API can do with your own Image files.
- Runs in your browser, nothing to install.
- See how Aspose.Slides converts files before you write code.
- Upload Image files and save them as PDF.
- Download the result or convert more files.
Convert Image To Other Supported Formats
You can also convert images and save them to other file formats.