Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

I want to add runtime Text or Image watermark on pdf using iText1.3 api

801428Jan 13 2011 — edited Jan 13 2011
Hi all,
I want to add a watermark(text or image) at the runtime, I am creating pdf file with using iText 1.3 api.
It created fine. I have following code for add watermark for an existining file.

<code>
try {
PdfReader reader = new PdfReader("ConfirmBillPDF.pdf");
int n = reader.getNumberOfPages();

PdfStamper stamp = new PdfStamper(reader, new FileOutputStream("NewPDFWithWatermarkImage.pdf"));
int i = 0;
PdfContentByte under;
Image img = Image.getInstance("ValidityExpWaterMark.png");
img.setAbsolutePosition(100, 400);
while (i < n)
{
i++;
under = stamp.getUnderContent(i);
under.addImage(img);
}
stamp.close();
}
catch (Exception de)
{
de.printStackTrace();
}

</code>

But I want to add this with runtime.

Plese help me..
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 10 2011
Added on Jan 13 2011
1 comment
329 views