Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies within .NET ( C#, VB.NET, ASP.NET, .NET Core) application and Java (J2SE and J2EE) application.

Sat Oct 01, 2011 3:18 pm


I have downloaded the evaluation version of Spire.PDF.

I would like to add a text or image watermark to an existing pdf.

I need to open/load the pdf and go to a particular page and add a watermark.

Alternatively, add watermark to all pages of the existing pdf.

Could you please help with some sample code that will explain how this could be done.

Looking for an early reply as I need to get it working and inform that client

Thanking you

Best Regards,


Posts: 1
Joined: Sat Oct 01, 2011 5:02 am

Mon Oct 10, 2011 1:22 am


Sorry for late reply and thank you for your patience with our reply.
If you want to add image or text watermark for the existing Pdf, you can try the following code:
Code: Select all
            PdfDocument doc = new PdfDocument(@"..\..\Sample1.pdf");
            Image img = Image.FromFile(@"..\..\Background.png");
            for (int i = 0; i <doc.Pages.Count; i++)
                //add image to the existing pdf file
                doc.Pages[i].BackgroundImage = img;
               //add Text WaterMark               
                PdfTilingBrush brush
                = new PdfTilingBrush(new SizeF(doc.Pages [i].Canvas.ClientSize.Width /2,doc.Pages  [i].Canvas.ClientSize.Height / 3));
                brush.Graphics.TranslateTransform(brush.Size.Width / 2, brush.Size.Height / 2);
                brush.Graphics.DrawString("Spire.Pdf Demo",
                    new PdfFont(PdfFontFamily.Helvetica, 24), PdfBrushes.Violet, 0, 0,
                    new PdfStringFormat(PdfTextAlignment.Center));
                doc.Pages[i].Canvas.DrawRectangle(brush, new RectangleF(new PointF(0, 0), doc.Pages[i].Canvas.ClientSize));

If you still have any questions, please don't hesitate to contact us at any time for any thing.
Have a nice day.

Thanks and Regards.
Technical Support/Developer,
e-iceblue Support Team
User avatar

Posts: 152
Joined: Tue Sep 13, 2011 5:37 am

Return to Spire.PDF