I am taking the section example in the documentation and trying to add a footer to it, the page number is not lining up with footer. What do I need to do to get things to line up correctly? I would like the footer to be lowered, not the page number raised:
public static void Run() { Report report = new Report(); // Create the main Section ISection section = report.AddSection(); section.PageMargins.All = 40; // CreateHeader(section); // Get a reference to the section's PageNumbering object. Infragistics.Documents.Report.Section.PageNumbering pn = section.PageNumbering; // Create a style for the page numbering font. pn.Style = new Infragistics.Documents.Report.Text.Style(Fonts.Arial, Infragistics.Documents.Graphics.Brushes.Black); // The Template property is the actual string that // shows the page numbering. Use the [Page #] place- // holder for the current page and the [TotalPages] // place-holder for the total amount of pages in // the entire document. pn.Template = "Page [Page #] of [TotalPages]"; // Setting SkipFirst to true does not place page // numbering on the first page of the section. This // is useful if the first page is a Title page. pn.SkipFirst = false; // The page numbering will be aligned with the // right side of the page. Valid values off the // Alignment enum include Left, Center, and Right. pn.Alignment.Horizontal = Infragistics.Documents.Report.Alignment.Right; // The page numbering will be located at the // bottom of the page. Valid values off the // Alignment enum include Top and Bottom. pn.Alignment.Vertical = Infragistics.Documents.Report.Alignment.Bottom; // The page numbering is at the extreme bottom // of the page, so we need to change the Y Offset // in order to bring it in line with the rest of // the page footer text. pn.OffsetY = -18; ISectionFooter footer = section.AddFooter(); footer.Height = 30; IText text = footer.AddText(0, -18); text.AddContent(string.Format("Date printed: {0}", DateTime.Now.ToString("dd-MM-yyyy"))); string reportName = GetPDFName(".pdf"); report.Publish(reportName, FileFormat.PDF); System.Diagnostics.Process.Start(reportName); }
public static void Run()
{
Report report = new Report();
// Create the main Section
ISection section = report.AddSection();
section.PageMargins.All = 40;
// CreateHeader(section);
// Get a reference to the section's PageNumbering object.
Infragistics.Documents.Report.Section.PageNumbering pn = section.PageNumbering;
// Create a style for the page numbering font.
pn.Style = new Infragistics.Documents.Report.Text.Style(Fonts.Arial, Infragistics.Documents.Graphics.Brushes.Black);
// The Template property is the actual string that
// shows the page numbering. Use the [Page #] place-
// holder for the current page and the [TotalPages]
// place-holder for the total amount of pages in
// the entire document.
pn.Template = "Page [Page #] of [TotalPages]";
// Setting SkipFirst to true does not place page
// numbering on the first page of the section. This
// is useful if the first page is a Title page.
pn.SkipFirst = false;
// The page numbering will be aligned with the
// right side of the page. Valid values off the
// Alignment enum include Left, Center, and Right.
pn.Alignment.Horizontal = Infragistics.Documents.Report.Alignment.Right;
// The page numbering will be located at the
// bottom of the page. Valid values off the
// Alignment enum include Top and Bottom.
pn.Alignment.Vertical = Infragistics.Documents.Report.Alignment.Bottom;
// The page numbering is at the extreme bottom
// of the page, so we need to change the Y Offset
// in order to bring it in line with the rest of
// the page footer text.
pn.OffsetY = -18;
ISectionFooter footer = section.AddFooter();
footer.Height = 30;
IText text = footer.AddText(0, -18);
text.AddContent(string.Format("Date printed: {0}", DateTime.Now.ToString("dd-MM-yyyy")));
string reportName = GetPDFName(".pdf");
report.Publish(reportName, FileFormat.PDF);
System.Diagnostics.Process.Start(reportName);
}
Hi,
If you want the page footer to be lower, you need to change the Margins. The Margins are what is making the footer appear so high on the page.
Mike,
I took the time to provide a complete working example in hopes that you or someone else could simply go in and add the few lines of code to make it look correctly. There are really only a few extra lines from an example I got from the Infragistics documentation.