BoldDeskBoldDesk is now live on Product Hunt with a special offer: 50% off all plans. Let's grow together! Support us.
Hi Ivan,
Thank you for using syncfusion products,
We can print the number each page in footer by using the PdfPageNumberField, PdfPageCountField and PdfCompositeField
Please refer the below code snippet to create composite field.
//Creates a new PDF document.
PdfDocument pdfDocument = new PdfDocument();
//Adds a page to the PDF document
PdfPage pdfPage = pdfDocument.Pages.Add();
pdfDocument.Pages.Add();
RectangleF rect = new RectangleF(0, 0, pdfDocument.Pages[0].GetClientSize().Width, 50);
//Footer.
//Creates a Template that can be used as footer.
//Creates a page template.
PdfPageTemplateElement footer = new PdfPageTemplateElement(rect);
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 7);
PdfBrush brush = new PdfSolidBrush(Syncfusion.Drawing.Color.Black);
//Creates page number field.
PdfPageNumberField pageNumber = new PdfPageNumberField(font, brush);
//Creates page count field.
PdfPageCountField count = new PdfPageCountField(font, brush);
//Adds the fields in composite fields.
PdfCompositeField compositeField = new PdfCompositeField(font, brush, "Page {0} of {1}", pageNumber, count);
compositeField.Bounds = footer.Bounds;
//Draws the composite field in footer.
compositeField.Draw(footer.Graphics, new PointF(470, 40));
//Adds the footer template at the bottom.
pdfDocument.Template.Bottom = footer;
//Saves the document.
MemoryStream stream = new MemoryStream();
pdfDocument.Save(stream);
pdfDocument.Close(true);
Please let us know if you need further assistance.
With Regards,
Praveen