mxPage = mxDocument.Pages.Add();
RectangleF rect = new RectangleF(0, 0, doc.Pages[0].GetClientSize().Width, 192);
//Create page template
PdfPageTemplateElement header = new PdfPageTemplateElement(rect);
string physicalPath = Path.Combine(HostingEnvironment.WebRootPath, "images", "pdf_banner_210mm.jpg");
Stream file2 = new FileStream(physicalPath, FileMode.Open, FileAccess.Read, FileShare.Read);
PdfImage img = new PdfBitmap(file2);
//Draw the image in the Header.
header.Graphics.DrawImage(img, 0, 0, imageWidth, imageHeight);
file2.Dispose();
//Add header template at the top.
mxDocument.Template.Top = header; //Adds to ALL pages
I have tried the following:
PdfSection section1 = mxDocument.Sections.Add();
section1.Pages.Add();
section1.Pages.Add();
.........>
section1.Template.Top = header; //Adds to All but the First Page.
PdfSection section1 = mxDocument.Sections.Add();
section1.Pages.Add();
//add new section and pages
PdfSection section2 = mxDocument.Sections.Add();
section2.Pages.Add();
//Add header to first page section
section1.Template.Top = header; |
//Adding a new page
mxPage = mxDocument.Pages.Add();
//Adding sections
PdfSection section1 = mxDocument.Sections.Add();
section1.Pages.Add();
PdfSection section2 = mxDocument.Sections.Add();
section2.Pages.Add();
|
//Draw the PdfGrid.
headerGrid.Draw(mxPage, new PointF(50, 250));
|
//Adding sections
PdfSection section1 = mxDocument.Sections.Add();
mxPage = section1.Pages.Add();
PdfSection section2 = mxDocument.Sections.Add();
section2.Pages.Add(); |
There is still a problem with this solution
if you let the data grid continue to a second page the header still gets added to the second page
How can you let a data grid span multiple pages with the header only showing on the first page
HI Gowthamraj
This Solution seems to be working for me. Thank you for the response with the right solution, much appreciated
Regards