Dynamic Footer


#1

I have an application with a footer and a header “hard coded” in the xml (see below), and a lot of dyamic content within them. Now I need to add a line to the footer with some dynamic content, and Ive been unable to do so. Ive followed the code in the online docs under the HeaderFooter class and have looked her in the pdf forum, but nothing prints out.
Can you help me?
By the way, how do you tell HeaderFooter that you want something to print out as a footer? I dont see anything like a pdf.section.IsFooter property.
Thanks, Mark


*** XML (stripped down from actual source):




Page $p




PRIVATE/PROPRIETARY






** cs (stripped down from actual source)
public void BuildPdfTitles(Pdf myPdf,Employee emp,string reportForName)
{
Section pdfTitleLine1 = myPdf.Sections[“EmpSumSection”];

// Footer which doesnt work, nothing prints out
HeaderFooter hf = new HeaderFooter(pdfTitleLine1);
hf.Paragraphs = new Paragraphs();
Text txtFtr = new Text(hf);
hf.Paragraphs.Add(txtFtr);
Segment segFtr = new Segment(txtFtr);
txtFtr.Segments.Add(segFtr);

segFtr.Content=reportForName; // dynamic footer content
Text dataText3 = (Text)pdfTitleLine1.Paragraphs[“EmpSumTitleName”];
Segment segment3 = dataText3.Segments[0];
segment3.Content = "Business Profile for: "+emp.LastFirstName;
Text dataText4 = (Text)pdfTitleLine1.Paragraphs[“EmpSumJobTitle”];
Segment segment4 = dataText4.Segments[0];
segment4.Content = emp.JobTitleIntl


#2

Dear MarkAurit,

Thanks for your consideration.

Here is an example showing how to add dynamic content to the footer:

[C#]
Pdf myPdf = new Pdf();
myPdf.BindXML(“Y:/c#/Pdf/Xml/Test/TestFooter.xml”,null);

Section pdfTitleLine1 = myPdf.Sections[“EmpSumSection”];

// Footer which doesnt work, nothing prints out
HeaderFooter hf = pdfTitleLine1.EvenFooter;

Text txtFtr = new Text(hf);
hf.Paragraphs.Add(txtFtr);
Segment segFtr = new Segment(txtFtr);
txtFtr.Segments.Add(segFtr);

segFtr.Content=“dynamic footer content”; // dynamic footer content

myPdf.Save(“d:/temp/test.pdf”);

[Visual Basic]
Dim myPdf As Pdf = New Pdf()
myPdf.BindXML(“Y:/c#/Pdf/Xml/Test/TestFooter.xml”,Nothing)

Dim pdfTitleLine1 As Section = myPdf.Sections(“EmpSumSection”)

’ Footer which doesnt work, nothing prints out
Dim hf As HeaderFooter = pdfTitleLine1.EvenFooter

Dim txtFtr As Text = New Text(hf)
hf.Paragraphs.Add(txtFtr)
Dim segFtr As Segment = New Segment(txtFtr)
txtFtr.Segments.Add(segFtr)

segFtr.Content=“dynamic footer content” ’ dynamic footer content

myPdf.Save(“d:/temp/test.pdf”)


#3

Thank you. A related questions: what is the difference between EvenFooter and OddFooter? I thought, since the documentation didnt say anything about it, that EvenFooter prints on even pages only and OddFooter odd pages.
Sincerely, Mark


#4

Dear MarkAurit,

Thanks for your consideration.

Yes, EvenFooter prints on even pages only and OddFooter odd pages. If you haven’t set the ‘Type’ property of Header or Footer to ‘odd’ or ‘even’ in xml, Header or Footer will print on both odd and even pages.


#5

I implemented the c# code close to exactly as above (with a few seg. properties for formatting) and get the footers on all pages (odd and even) - which was just as I wanted, so Im not complaining!