Watermark on PDF not working after 4th page in IHttpModule event

We have an requirement from our client to implement watermark when a document will be downloaded from MOSS2007 document library.

I am adding a watermark when user trying to download a document from MOSS2007 document library. The process is executing properly but not adding water mark after 4 th page. I have tried with multiple pdf documents but always it it working fine for first 4 pages.

Please find my as at attachemnt .

Hi Sonjay,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.Pdf.

Well, as you are working with evaluation copy of Aspose.Pdf for .NET (without a license), you are facing an evaluation restriction. In evaluation version only 4 items of any collection are allowed to be processed. For testing purpose, you may get a 30 days free temporary license. For that, please use the below link to acquire a temporary license (choose “Get a Temporary License” option).

http://www.aspose.com/purchase/default.aspx

Thank You & Best Regards,

Thanks Aslam for your reply. I have received the temporary license and the existing problem has been resolved. But now the issue is and adding the watermark the document is not opening. We are doing a POC for our existing customer. Please find the attachemt of the error.

Find the following code below

using (Stream inputStream = new MemoryStream(content))

{

Aspose.Pdf.License license = new Aspose.Pdf.License();

license.SetLicense("C:\\Aspose.Pdf.lic");

Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(inputStream);

MemoryStream outStream = new MemoryStream();

// foreach (Aspose.Pdf.Page pdfPage in pdfDocument.Pages-1)

for (int i=1;i<=pdfDocument.Pages.Count;i++)

{

Aspose.Pdf.Facades.FormattedText obj = new Aspose.Pdf.Facades.FormattedText(watermark, System.Drawing.Color.Brown, Aspose.Pdf.Facades.FontStyle.HelveticaBold, Aspose.Pdf.Facades.EncodingType.Cp1252,true,20);

Aspose.Pdf.Page pdfPage = pdfDocument.Pages[i];

//create text stamp

Aspose.Pdf.TextStamp textStamp = new Aspose.Pdf.TextStamp(obj);

//set whether stamp is background

textStamp.Background = false;

textStamp.Opacity = 0.2F;

pdfPage.AddStamp(textStamp);

}

pdfDocument.Save(outStream);

content = outStream.ToArray();

Thanks & Rergards

Sonjay

Hi Sonjay,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for the feedback.

Please share your input and output PDF documents with us for testing of your issue. We will check it and get back to you soon.

Sorry for the inconvenience,

Hi Aslam,

Thanks for your help. Please find the Input.pdf and Output.pdf as requested.

Waiting for your feedback.

Thanks

Sonjay

Hi Sonjay,


Thanks for sharing the resource files and sorry for the delayed response.

I have tested the scenario of adding watermark to PDF file using Aspose.Pdf for .NET 7.6.0 and I am unable to notice any issue. The watermark text is appearing on all pages of PDF file and I did not notice any issue while opening the file. Can you please try using the latest release version and in case you still face the same problem or you have any further query, please feel free to contact. We are sorry for your inconvenience.

PS, For your reference, I have also attached the output PDF file containing watermark which I have generated over my end. Please take a look.