How to add watermark to first 5 pages to PDF

In the watermark documentation watermark can be applied to specific page of PDF but can u please provide a solution to apply watermark to first 5 pages.

1 Like

@shiva.k

Currently, API doesn’t support such a feature. However, the workaround is to iterate the process as follows:

//Java code to add text watermark to first five pages of a PDF 
for (int i = 0; i < 5; i++) 
{ 
TextWatermark textWatermark = new TextWatermark("This is a test watermark", new Font("Arial", 8));
PdfArtifactWatermarkOptions textWatermarkOptions = new PdfArtifactWatermarkOptions(); 
textWatermarkOptions.setPageIndex(i); 
watermarker.add(textWatermark, textWatermarkOptions);
}

We have opened the following new ticket (a feature request) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WATERMARKJAVA-111

You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.