Write Text to the Printer and Position the Printer Head

The first step in report generation is to write text to the printer or position the printer head. These methods include:

Each method is described below.

Use the Write Method

There are 3 overloaded write methods:

public int Write(char[] chars)

This method writes an array of type char to the printer. It will write the entire array including any embedded nulls or control characters.

public int Write(string str)

This method writes a string to the printer.

public int Write(byte[])

This method writes the contents of a byte array to the printer.

All methods return:

Example:

lp.Write("This is a line of normal text.");

See this method in the LinePrinter Class information

Use the WriteFile Method

This method sends a file directly to the printer without processing. The most common use of this function is to print a report that has already been formatted for a specific printer. The report is buffered in a file and then printed in one function call.

Note that all graphics or printer control characters must already be embedded in the file and formatted for the specific printer before before it is sent to the printer.

Properties such as PageNumber are not updated by this function, and therefore will be incorrect after the function is called.

public int WriteFile(string FileName)

Returns:

See this method in the LinePrinter Class information

Use the ActualFormFeed Method

This command sends a form feed character to the printer. It is useful if you wish to align the top of page without generating any headers or footers. To go to the top of page and still produce headers and footers, use the FormFeed method.

public int ActualFormFeed()

Returns:

Example:

lp.ActualFormFeed();

See this method in the LinePrinter Class information

Use the FormFeed Method

This method steps the printer down to the top of the new page generating headers and footers as needed.  Because this method steps the printer down line by line, it is generally slower than the ActualFormFeed method.

public int FormFeed()

Returns:

Example:

lp.FormFeed();

See this method in the LinePrinter Class information

Use the NewLine Method

This method sends any buffered text to the printer, causes the paper to advance to a new line and positions the printer head at the start of that line. You need to call this function to advance the paper (as opposed to embedding new line character codes into your text) if you want the LinePrinter object to keep track of line and page numbers and properly place headers and footers.

public int NewLine()

Returns:

Example:

lp.NewLine();

See this method in the LinePrinter Class information

Use the Bitmap Method

This method prints a BMP file to a printer that supports graphics printing. The bitmap will be stretched to fit the height and width selected. Automatic orphan control is built into this function. This action is undefined if the sum of the starting column plus the BMP width is greater than the printable width.

public int Bitmap(
uint _dwStartCol,
uint dwHeight,
uint wWidth,
string sFilename);

Returns:

Example:

lp.Bitmap(5,15,5,"Signature.BMP");

See this method in the LinePrinter Class information

More Information

Next » Generate a Report: Change the Font Style

Back « Generate a Report