[PDF] add watermark to pdf

Hi All,


My project requires to add watermark on every page of PDF, I searched the forge, seems there is no components can help to achieve this goal, could anyone show me how to do it?

Hi Yi,

I'd say it depends on how you're going to generate the PDF, but I see this as CSS: you'd use something like HTML2PdfConverter and in the page(s) that you output in the PDF file, you'd add whatever content you'd like and style it as a watermark - in the corners or in the center of the page with absolute positioning and a lighter color than your text.

Hi Yi,

Afonso is right that its depends which generater you are using for PDF.

i am using PDFLibrary for PDF generate here is the many option for this

so you can use this one also.

hope this will help you.


Kind Reagrds

Rahul Sahu

Afonso Carvalho wrote:

Hi Yi,

I'd say it depends on how you're going to generate the PDF, but I see this as CSS: you'd use something like HTML2PdfConverter and in the page(s) that you output in the PDF file, you'd add whatever content you'd like and style it as a watermark - in the corners or in the center of the page with absolute positioning and a lighter color than your text.


Hi Afonso, 

Thanks for the reply, I would agree to do that, but if say it needs several pages, say 5, to print out a table for records, how would it be like to configure generate PDF so CSS actually applies to all pages?

Rahul Sahu wrote:

Hi Yi,

Afonso is right that its depends which generater you are using for PDF.

i am using PDFLibrary for PDF generate here is the many option for this

so you can use this one also.

hope this will help you.


Kind Reagrds

Rahul Sahu

Hi Rahul,

Thanks for the reply, but which component provides this PDFLibrary? I couldn't find it in forge.


Solution

Yi Ouyang wrote:

Hi Afonso, 

Thanks for the reply, I would agree to do that, but if say it needs several pages, say 5, to print out a table for records, how would it be like to configure generate PDF so CSS actually applies to all pages?

There's a couple of CSS solutions that I'm aware of, but the best one will depend on the remaining content of your PDF:

a) Elements with "position: fixed" should repeat in every page. You can create a fixed container and place your watermark content there;

b) Table headers and footers will repeat in every page if set with "display: table-header-group";

I'd recommend trying the first one and seeing if adjustments are needed with your layout. You also have the option to generate headers and footers with wkhtmltopdf (the library behind the OutSystems module I linked), but you'll be restricted to just the header or footer as the places for your watermark.


Solution