If you’ve been struggling to find a solution for inserting images into a PDF, look no further. With JPedal you now have the ability to insert images into PDF files using a few lines of Java.
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 |