Convert Image to PDF in Java
Convert image files to PDF documents using Aspose.Slides for Java without Microsoft PowerPoint.
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.
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();
}
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.
Free Online Converter
Convert presentations and slides online.
Convert Image To Other Supported Formats
You can also convert images and save them to other file formats.