2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
Adding page number to exported pdf documentYou can add page numbers in the header or footer of the exported PDF document using the dynamic fields: PdfPageNumberField and PdfCompositeField. C# PdfExportingOptions options = new PdfExportingOptions(); options.RepeatHeaders = true; options.ExportGroupSummary = true; options.ExportFormat = true; options.FitAllColumnsInOnePage = false; options.ExportTableSummary = true; //Set document information. Syncfusion.Pdf.PdfDocument document = new Syncfusion.Pdf.PdfDocument(); RectangleF bounds = new RectangleF(0, 10, document.Pages[0].GetClientSize().Width, 50); PdfPageTemplateElement footer = new PdfPageTemplateElement(bounds); PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 7); PdfBrush brush = new PdfSolidBrush(Color.Black); //Create page number field. PdfPageNumberField pageNumber = new PdfPageNumberField(font, brush); //Add the fields in composite fields. PdfCompositeField compositeField = new PdfCompositeField(font, brush, "{0}", pageNumber); compositeField.Bounds = footer.Bounds; //Draw the composite field in footer. compositeField.Draw(footer.Graphics, new PointF(250, 40)); //Add the footer template at the bottom. document.Template.Bottom = footer; var pdfGrid = sfDataGrid1.ExportToPdfGrid(sfDataGrid1.View, options); pdfGrid.Draw(page, new PointF()); VB Dim options As New PdfExportingOptions() options.RepeatHeaders = True options.ExportGroupSummary = True options.ExportFormat = True options.FitAllColumnsInOnePage = False options.ExportTableSummary = True 'Set document information. Dim document As New Syncfusion.Pdf.PdfDocument() Dim page = document.Pages.Add() Dim bounds As New RectangleF(0, 10, document.Pages(0).GetClientSize().Width, 50) Dim footer As New PdfPageTemplateElement(bounds) Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 7) Dim brush As PdfBrush = New PdfSolidBrush(Color.Black) 'Create page number field. Dim pageNumber As New PdfPageNumberField(font, brush) 'Add the fields in composite fields. Dim compositeField As New PdfCompositeField(font, brush, "{0}", pageNumber) compositeField.Bounds = footer.Bounds 'Draw the composite field in footer. compositeField.Draw(footer.Graphics, New PointF(250, 40)) 'Add the footer template at the bottom. document.Template.Bottom = footer Dim pdfGrid = sfDataGrid1.ExportToPdfGrid(sfDataGrid1.View, options) pdfGrid.Draw(page, New PointF()) Samples: C# : PageNumber VB : PageNumber Reference link: https://help.syncfusion.com/windowsforms/datagrid/exporttopdf |
2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.