[Overview][Types][Classes][Variables][Index] | Reference for unit 'Printers' (#lcl)

# TPrinter.BeginDoc

Starts printing for the current document.

## Declaration

Source position: printers.pas line 312

`public procedure TPrinter.BeginDoc;`

## Description

BeginDoc is a procedure used to start printing for the current document. BeginDoc calls CheckPrinting to ensure that the print device has not already started printing for the document. CheckPrinting raises an exception if the value in Printing is True.

BeginDoc calls SelectCurrentPrinterOrDefault to ensure a valid printer is selected for the class instance. If the current selection is invalid, the "default" printer is selected. The default printer is the first one in Printers.

BeginDoc updates PrinterFlags to include the value pfPrinting, and removes the value pfAborted (if present). The PageNumber property is reset for the newly started printing operation.

BeginDoc uses the value in RawMode to determine if a printer canvas is in used for the class instance. When RawMode is False, a TPrinterCanvas instance exists in Canvas. Its Refresh method is called, and the BeginDoc method in the printer canvas is called to synchronize the canvas. The value in YDPI is assigned to the PPI (Pixels per Inch) setting for the canvas font. No actions are performed for the printer canvas when RawMode is True.

BeginDoc calls the DoBeginDoc method to perform any actions specific to the current class implementation. BeginPage is called to increment the PageNumber for the print device.

Use EndDoc to finish printing for the current document.

## See also

TPrinter.RawMode |  | Indicates if raw output is used for the device (as opposed to a page description language).
TPrinter.Printing |  | True if the document is currently being printed.
TPrinter.PrinterFlags |  | Status flags currently enabled for the print device.
TPrinter.Canvas |  | The Canvas to be used for laying out the current document ready for printing.
TPrinter.SelectCurrentPrinterOrDefault |  | Selects the default printer when a printer has not been selected.
TPrinter.PrinterIndex |  | Contains the ordinal position in Printers for the selected print device.
TPrinter.PageNumber |  | Current page number in the document being printed to the device.
TPrinter.BeginPage |  | Begins a page on the print device.
TPrinter.SetPrinter |  | Makes the device with the specified name the current printer.
TPrinter.EndDoc |  | Ends printing for the current document.
TPrinterCanvas |  | Implements a canvas used for TPrinter device output.