PDF Mosaic: How to add text watermark to page


Home       Features       Download       Tutorial       Version History       License       Source Code

 

This sample shows how to add text watermarks onto every page of your PDF document. Example draws a simple text watermark on each PDF page. There is abstract class PDFWatermak represents PDF watermark. PDF document has property Watermarks for storing watermarks in the collection. There is class PDFTextWatermark for adding text watermark to PDF file.

            PDFDocument pdf = new PDFDocument();
            for (int i = 0; i < 5; ++i)
            {
                pdf.Pages.Add(new PDFPage(PDFPaperFormat.A4));
            }
 
            PDFTextWatermark watermark = new PDFTextWatermark("PDF Mosaic .NET Library");           
            watermark.Left = pdf.Pages[0].Width / 2 - 175;
            watermark.Top = pdf.Pages[0].Height / 2;
            watermark.Font.Size = 30;
 
            for (int i = 0; i < pdf.Pages.Count; ++i)
            {
                pdf.Pages[0].Watermarks.Add(watermark);
            }
 
            pdf.Save("TestCenterpageTextWatermaks.pdf", true);

 


Home       Features       Download       Tutorial       Version History       License       Source Code