Create Header and Footer Text and Control Orphans

The LinePrinter class includes two methods for controlling your own footers and headers and for orphan control. You can also specify headers and footers automatically in your report via the FooterEvent and HeaderEvent described below.

LineWillFit Method

This method returns true if at least one more line may be printed before any defined footer lines or a new page.  Otherwise it returns false.

public bool LineWillFit()

Return:

Example:

bool b = lp.LineWillFit();

See this method in the LinePrinter Class information

NoOrphan Method

Use this method to define the number of lines you wish to make sure are printed together without orphaning.

public int NoOrphan(uint NumLines, OrphanMode om)

where:

NumLines
The number of lines you wish to make sure are printed together without orphaning.

om
The type of orphan protection desired. The choices are:

Returns:

Example:

lp.NoOrphan(5,NLPOM_CURRENT);

See this method in the LinePrinter Class information

FooterEventEx Event

This event is used to register your footer method to be executed by the LinePrinter at the bottom of the page.  Note that you should not perform any persistent calculations within the method as the applications footer method will be called once at the beginning of the report to calculate how many lines are generated by it.

public event FooterEventHandler FooterEventEx:

An example application footer method (albeit unlikely) might be:

public void PrintFooter(object source, EventArgs evnt)
{
    lp.NewLine();
    lp.NewLine();
    lp.Write(string.Format("This is the Footer for page {0} of the report",lp.PageNumber));
    lp.NewLine();
    lp.NewLine();
}

Example:

lp.FooterEventEx += new  LinePrinter.FooterEventHandler(PrintFooter);

The static version of this event (FooterEvent) has been obsoleted and may not be supported in future versions of this assembly.

See this event in the LinePrinter Class information

HeaderEventEx Event

This event is used to register your header method to be executed by the LinePrinter at the top of each new page.

public event HeaderEventHandler HeaderEventEx;

An example application header method (albeit unlikely) might be:

public void PrintHeader(object source, EventArgs evnt)
{
    lp.NewLine();
    lp.NewLine();
    lp.Write(string.Format("This is the Header for page {0} of the report",  
    lp.PageNumber));
    lp.NewLine();
    lp.NewLine();
}

Example:

lp.HeaderEventEx += new LinePrinter.HeaderEventHandler(PrintHeader);

The static version of this event (HeaderEvent) has been deprecated.

See this event in the LinePrinter Class information

More Information

Next » Generate a Report: Return the Current Status of a Print Job

Back « Generate a Report: Change the Font Style