Are you a Java Developer working with PDF files?

Find out why you should be using JPedal

How to insert an image into a PDF

18 sec read

Recently, we released JPedal 2023.07 which contains the ability to insert images into PDF files.

All you need is a copy of JPedal, a BufferedImage, and a few lines of Java.

final WritableAnnotation[] annotations = new WritableAnnotation[1];

annotations[0] = new ImageAnnotation(page, x0, y0, x1, y1, bufferedImage);

AnnotationWriter.writeAnnotations(new File("input.pdf"), new File("output.pdf"), annotations);

The bottom left corner of the image will be at (x0, y0) and the top right corner will be at (x1, y1). The image is scaled to fit within these bounds.


Our software libraries allow you to

Convert PDF to HTML in Java
Convert PDF Forms to HTML5 in Java
Convert PDF Documents to an image in Java
Work with PDF Documents in Java
Read and Write AVIF, HEIC, WEBP and other image formats