watermark (text or image) in existing pdf

How do I include a watermark (text or image) in an existing pdf in c#?

I want the watermark displayed for all pages of the pdf.

I attempted with itextsharp but the watermark is displaying in only last page of the pdf.

You are adding the watermark under the existing material at hard-code collaborates x = 0; y = 0. Possibly the pages that don’t show the watermark are opaque and/or maybe they have a different coordinate system (the lower-left corner doesn’t constantly have the coordinate 0, 0). Without seeing the real PDF you want to watermark, we can’t really assist. Did you check out The best ways to add a watermark to a page with a nontransparent image? & How to watermark?

The code below adds both a text watermark and a transparent image watermark to an existing pdf.

By Itextsharp i am getting the watermark in all the pages however by utilizing GetUnderContent the watermark is hiding on the content and on the last page it is revealing. By Utilizing GetOverContent it is showing in all the pages however above the content the content is concealing

I am attempting to programmatically develop a number of PDF files with a watermark on each page using itextsharp (a C# port of Java’s itext).

I have the ability to do this after the file has been produced using a PdfStamper. This appears to include re-opening the document reading it and then producing a new file with the watermark on each page.

Is there a method of doing this throughout file development?

After digging into it I discovered the very best way was to add the watermark to each page as it was developed. To do this I developed a new class and carried out the IPdfPageEvent interface as follows:

This will add a watermark on all pages of a PDF document that is supplied as a byte variety.

( You don’t require to do it while developing the PDF.).

It seems working for both landscape and portrait and it most likely works for files with blended orientations.

You might prefer the one-pass alternative presented by Tim since it uses less resources if your usage case is develop a new PDF and add a watermark. Your option is appropriate if your use case is take an existing PDF and watermark it.

Leave a Reply

Your email address will not be published. Required fields are marked *