We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Header different for eachpage

Thread ID:





121265 Nov 24,2015 05:07 PM UTC Nov 25,2015 12:43 PM UTC Silverlight 1
Tags: PDF
Asked On November 24, 2015 05:07 PM UTC


I need to add a "parameter" in my header :
I have a title that include the report date (i have this parameter in my code) and for each page in the pdf, i have a different date.
I can't create a title outside the header since content can be on 2 page (when grid has too much line)

Thanks in advance,


Abirami Selvan [Syncfusion]
Replied On November 25, 2015 12:43 PM UTC

Hi Anthony,
Thank you for contacting Syncfusion support.
We can draw the grid table with particular paginate bounds and can add the different headers using sections for each page. We have created the code according to your requirement.
Please refer to the in the following code example:


// Create a new PdfDocument

PdfDocument document = new PdfDocument();

// Add a page

PdfPage page=document.Pages.Add();

//Create the pdfgrid

PdfGrid pdfGrid = new PdfGrid();

//Add grid columns


//Add the grid row

for (int i = 0; i < 4; i++)


//Assign the values to table

for (int i = 0; i < 30; i++)


pdfGrid.Rows[i].Cells[0].Value = i.ToString() + " Row ";


//Apply the pagination

PdfGridLayoutFormat gformat = new PdfGridLayoutFormat();

gformat.Layout = PdfLayoutType.Paginate;

gformat.Break = PdfLayoutBreakType.FitPage;

gformat.PaginateBounds = new RectangleF(10, 10, page.GetClientSize().Width, page.GetClientSize().Height);

//Draw the table

pdfGrid.Draw(page, new PointF(0, 10), gformat);

MemoryStream ms = new MemoryStream();

// Save and close the document.



ms.Position = 0;

//Load the file stream that contains the grid.

PdfLoadedDocument ldoc = new PdfLoadedDocument(ms);

//Create the document.

PdfDocument finalDoc = new PdfDocument();

//set the margins


for (int i = 0; i < ldoc.Pages.Count; i++)


//Get the templates from loadeddocument.

PdfTemplate template = ldoc.Pages[i].CreateTemplate();

//Add the sections

PdfSection section1 = finalDoc.Sections.Add();

PdfPage page1 = section1.Pages.Add();

//Draw the templates

page1.Graphics.DrawPdfTemplate(template, new PointF(0,0),new SizeF(page1.GetClientSize().Width,page1.GetClientSize().Height));

//Including header to the section

section1.Template.Top = AddHeader(finalDoc, DateTime.Now.Date.ToShortDateString());


MemoryStream stream = new MemoryStream();

//Desired document is saved and opened

SaveFileDialog saveDialog = new SaveFileDialog()


DefaultExt = ".pdf",

Filter = "Adobe PDF Files(*.pdf)|*.pdf",

FilterIndex = 1



using (Stream stream1 = saveDialog.OpenFile())




//close the document



MessageBox.Show("Document has been successfully generated", "Essential PDF", MessageBoxButton.OK);

private PdfPageTemplateElement AddHeader(PdfDocument doc, string title)


RectangleF rect = new RectangleF(0, 0, doc.Pages[0].GetClientSize().Width, 50);

//Create page template

PdfPageTemplateElement header = new PdfPageTemplateElement(rect);

PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 16, PdfFontStyle.Bold);

//Set formattings for the text

PdfStringFormat format = new PdfStringFormat();

format.Alignment = PdfTextAlignment.Center;

format.LineAlignment = PdfVerticalAlignment.Middle;

//Draw title

header.Graphics.DrawString(title, font, PdfBrushes.Black, new RectangleF(0, 0, header.Width, header.Height), format);

header.Graphics.DrawRectangle(PdfPens.Blue, rect);

return header;


Please try  this and let us know if you need any further assistance.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon