Different watermark for 1st page and all subsequent pages

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v7)  /  Different watermark for 1st page and all subsequent pages

DynamicPDF CoreSuite for .NET (v7) Forum

Given a multipage PDF document, is it possible to add a watermark to the first page and a second watermark to all subsequent pages? The goal is to mimic printing onto company letterhead where the first page comes from one paper tray and subsequent pages from another.
Posted by a ceTe Software moderator
Hello,

Yes, you can achieve your requirement without any problem using our DynamicPDF ReportWriter for .NET product. You will need to create complete Document object using ReportWriter API. Then access the desired pages of the Document object using index and add watermark to it using Label and TransparencyGroup page elements. Below is the sample code for it.

            //Load the DPLX file using DocumentLayout class of ReportWriter API.
            DocumentLayout report = new DocumentLayout(@"C:\Temp\Test.dplx");
            Document document = report.Run();
            //Create watermark for the first page.
            ceTe.DynamicPDF.PageElements.Label watermark1 = new ceTe.DynamicPDF.PageElements.Label("Firsrt Page", 200, 400, 200, 30);
            watermark1.TextColor = RgbColor.Red;
            watermark1.FontSize = 25;
            TransparencyGroup group1 = new TransparencyGroup(0.2F);
            group1.Add(watermark1);
            //Access the first page using index and add this watermark text to it.
            Page firstPage = document.Pages[0];
            firstPage.Elements.Add(group1);

            //Create watermark for the rest of the pages.
            ceTe.DynamicPDF.PageElements.Label watermark2 = new ceTe.DynamicPDF.PageElements.Label("Rest of Pages", 200, 400, 200, 30);
            watermark2.TextColor = RgbColor.Red;
            watermark2.FontSize = 25;
            TransparencyGroup group2 = new TransparencyGroup(0.2F);
            group2.Add(watermark2);
            //Loop through the rest of the pages and addwatermark text.
            for (int i = 1; i < document.Pages.Count; i++)
            {
                Page page = document.Pages[i];
                page.Elements.Add(group2);
            }
            //Draw the PDF.
            document.Draw(@"C:\Temp\MyDocument.pdf");

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 11:33 AM.