TextElement on bottom of the last page

Hello,

I am using PDF for WPF.

I don`t know how many pages will document have (it is dinamic).

I want to add PdfTextElement only to the bottom of the last page (not like footer on every page).

How can I achieve this.

Thank You.



1 Reply

CM Chinnu Muniyappan Syncfusion Team December 27, 2016 11:08 AM UTC

Hi Vladimir, 
 
Thank you for contacting Syncfusion support. 
 
We can get the last page of the PDF document by using PdfLoadedPageCollection.PageCount property, we have created a sample for inserting PdfTextElement in bottom of the last page for your reference, please refer the below code snippet and sample for more details. 
            //Load the existing PDF document  
            PdfLoadedDocument ldoc = new PdfLoadedDocument("../../Barcode.pdf"); 
 
            //Get the PDF document page count 
            int pageCount = ldoc.Pages.Count; 
 
            //Get the last page 
            PdfLoadedPage lastPage = ldoc.Pages [pageCount-1] as PdfLoadedPage ; 
 
            //Create a new PDF text element 
            PdfTextElement lastPageElement = new PdfTextElement("This is the last page", new PdfStandardFont(PdfFontFamily.Helvetica, 15, PdfFontStyle.Bold), PdfBrushes.Red); 
 
            //Draw the text element to the last page of the document 
            lastPageElement.Draw(lastPage.Graphics, new System.Drawing.PointF(0, lastPage.Size.Height - 20)); 
 
            //Save the document  
            ldoc.Save("output.pdf"); 
 
            //Close the document 
            ldoc.Close(true); 
 
Sample Link: 
 
Let us know if you have any concern. 
 
Regards, 
Chinnu 


Loader.
Up arrow icon