Work with Images in PDF via Java
Manipulate images in PDF document. Use Aspose.PDF for Java to modify PDF documents programmatically
Most popular action with Images in Java
Add Image to PDF Document Using Java Library
In order to add Image in PDF, we’ll use Aspose.PDF for Java API which is a feature-rich, powerful, and easy-to-use conversion API for the Java platform. You can download its latest version directly from Maven and install it within your Maven-based project by adding the following configurations to the pom.xml.
Add Image to PDF via Java
You need Aspose.PDF for Java to try the code in your environment.
- Create a Document object and open the input PDF document.
- Get the page you want to add an image.
- Add the image into the page’s Resources collection.
- Use the GSave operator to save the current graphical state.
- Use ConcatenateMatrix operator to specify where the image is to be placed.
- Use the Do operator to draw the image on the page.
- Use GRestore operator to save the updated graphical state.
- Save the PDF file.