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?

iText library is one of the options

Since when is PDF read/write?

Since when is PDF read/write?

Well, only sort of. There are several writer objects in iText that allow you to import existing PDF content and generate new output content. I think that what the OP is wanting to do would be possible in iText, but I can't say from direct experience there.

Here is a bit of tutorial on manipulating existing docs with iText:
http://itextdocs.lowagie.com/tutorial/general/copystamp/index.html#inaction

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) {
startPageLoop++;
over = stamp.getOverContent(startPageLoop);
img.setAbsolutePosition(x, y);
over.addImage(img);
}
.
.
.
.
.end function
.
Thanks for your help anyway

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.