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.


Are you a Java Developer working with PDF files?

Free: The Java Developer's Guide to PDF
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

What is JPEG2000?

Alicia
54 sec read

What is PSD?

chika
52 sec read

What is PNG?

Mark Stephens
36 sec read