Good day,

I have a PDF file that acts as my template. I know how to use the x, y cordinate to put an image into that PDF file. My problem is that my PDF file has about five pages and I want to put this image in the second and forth page.

How do I do that?

11 Years
Discussion Span
Last Post by michael.ngobeni

It realy depends on what he is trying to do. He can always insert image/new data into existing documnet and they can be writen on new layer over existing content or he can put it below like a watermark. So michael you need to be more specific with this question...


I managed to get it.
I had a PDF file that had about 10 pages and I wanted to insert an image on every page.

This is what I did

import com.lowagie.text.Image;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfStamper;

. Start Class
private PdfReader reader=null;
private PdfStamper stamp=null;
private PdfContentByte over=null;
.Start function

reader = new PdfReader("MyPDFFile.pdf");
int NumberOfPages = reader.getNumberOfPages();
int startPageLoop = 0;

Image img;
img = Image.getInstance("C:\Images\Your_Mother.jpg");

while (startPageLoop < NumberOfPages) {
over = stamp.getOverContent(startPageLoop);
img.setAbsolutePosition(x, y);
.end function
Thanks for your help anyway

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.