PDFDocument Header

Hi, I am trying to use the Header template to add a header to each page of my PDFDocument. I need to be able to adjust the title of the page based on what section the page belongs to but other than that, all my header areas look the same. I found the code to add a header to the whole PDFDocument (pdfDoc.Templates.Header = header;) but when I try to adjust the header text based on a page range, by doing the following: for (int i = intStartPage; i <= intEndPage; i++) pdfDoc.Pages[i-1].Header = header; I get the following error message: "Cannot remove the specified item because it was not found in the specified Collection. " BUT if I do the following: pdfDoc.LastPage.Header = header; I can change the page title within the header area. The problem is, this changes only the last page within the a range of pages I would like to adjust the title for. Please help!

4 Replies

AD Administrator Syncfusion Team June 26, 2006 02:45 PM UTC

Hi Michelle, Sorry for the delay in getting back to you i was able to see the problem with your approach. However here is an alternative to do the same. Sample: Sample Please take a look at the sample let me if it helps you to resolve the problem. Thanks, Ajish.


AD Administrator Syncfusion Team June 26, 2006 07:18 PM UTC

This is not exactly what I was looking to do. This puts the same header on each page of the PDF document. I found this in Syncfusion''s Help area: Different headers and footers: If the document you are working on needs to have different headers and footers on various pages, you can use section breaks to achieve this. IPDFSection section = pdfDoc.AddSection(); section.BreakCode = SectionBreakCode.NewPage; But I do not know what assembly to include to be able to user the IPDFSection. Could you point me in the right direction? Will this let me assign a different header object to each section within the PDF? >Hi Michelle, > >Sorry for the delay in getting back to you i was able to see the problem with your approach. However here is an alternative to do the same. > >Sample: Sample > >Please take a look at the sample let me if it helps you to resolve the problem. > >Thanks, >Ajish. >


AD Administrator Syncfusion Team June 26, 2006 07:30 PM UTC

Please disregard the question about the sections within a PDF document, I found it and it only applies to the PDFLogicDocument, not the PDFDocumnet (FHI - that should be added to the help file for clarification). Can you still provide me an alternate way to adjust the headers within "sections" of a PDFDocument? I need to reserve the top for header information (each page will have the same look, but the title of the page will change with each new "section"). Thanks!! >This is not exactly what I was looking to do. This puts the same header on each page of the PDF document. > >I found this in Syncfusion''s Help area: >Different headers and footers: If the document you are working on needs to have different headers and footers on various pages, you can use section breaks to achieve this. > >IPDFSection section = pdfDoc.AddSection(); >section.BreakCode = SectionBreakCode.NewPage; > >But I do not know what assembly to include to be able to user the IPDFSection. Could you point me in the right direction? > >Will this let me assign a different header object to each section within the PDF? > >>Hi Michelle, >> >>Sorry for the delay in getting back to you i was able to see the problem with your approach. However here is an alternative to do the same. >> >>Sample: Sample >> >>Please take a look at the sample let me if it helps you to resolve the problem. >> >>Thanks, >>Ajish. >>


AJ Ajish Syncfusion Team June 27, 2006 06:04 PM UTC

Hi, Yes you are right, there is no concept of sections in Grid model [ PDFDocument]. Grid model deals only with pages in general. You can have different headers in different page with the help of page event handler and AddHeader helper function. Here is a sample for your reference: DifferentHeadersAndFooters.zip This sample contains some set of page with Page title as summary, funding and schedule. Please let me know if have any concerns. Thanks, Ajish.

Loader.
Up arrow icon