TRVPrint = class(TCustomRVPrint)
1.Assign the source component for printing (AssignSource method).
3.Format pages (FormatPages method).
4.Now you can:
▪get a number of pages (PagesCount property);
5.When finished, you can release some temporally allocated memory (Clear).
By default, the component prints on the default printer, using its default properties. The global Printer object provides access to the available printers. You can switch the printer by assigning Printer.PrinterIndex. You can change orientation of pages by assigning Printer.Orientation. After these changes, before printing or previewing, call FormatPages.
Alternatively, you can use "virtual printer" to draw pages on any canvas. Assign VirtualPrinter.Active = True to use parameters (page size and DPI) specified in VirtualPrinter, instead of parameters of the current printer.
You can display some information about the process of paginating and printing:
You can draw additional content using the following events:
▪OnPrintComponent requests an image of an inserted control for printing.
There are also informational events; they occurred when some special item is drawn. You can store coordinates of these items and implement special processing (for example, adding hyperlinks when printing to PDF using some third-party library).
Margins are specified in Margins property.
Margins in TRVPrint
This picture illustrates the meaning of margin properties. Paragraph indents are not shown for simplification.
Left and right margins can be swapped for even pages, if MirrorMargins is set to True.
See also ClipMargins property.
TRVPrint supports 3 types of headers and footers:
▪normal header and footer
▪header and footer for the first page (used only if TitlePage=True)
▪header and footer for even pages (used only if FacingPages=True)
Header and Footer
If a header and/or a footer is too long, size of the main document is adjusted to avoid overlapping:
Long Header Example
If you want more flexible headers / footers, consider:
▪printing document in several parts, each of them with its own header/footer;
▪using OnPagePrepaint event;
Some printers may have problems with advanced content (especially when you print to create PDF or metafile files). In this case, you can use the properties:
RVPrint contains an instance of TPrintableRV (descendant of TRichView) inside. This variable (named rv) is public and you can change some properties of it:
Changing other its properties is not recommended.
MyRVPrint.rv.Color := clWhite;
Note: this richview does not contain the full information about the printed document, just a formatting information; so you must provide that the source RichView is not destroyed while you are printing.
You can define the range of items to print, using MinPrintedItemNo and MaxPrintedItemNo properties. If these properties define a sub-range of items, only this sub-range (and only pages containing it) is printed.
These properties allow implementing an incremental printing: when the next portion of the document is ready, it can be printed below the previously printed fragment. This feature can be used for printing accounting journals, logs, etc.
The component draws a page content in the following order:
5.Header's text boxes and sidenotes having PositionInText=rvpitAboveText
6.Footer's text boxes and sidenotes having PositionInText=rvpitBelowText
8.Footer's text boxes and sidenotes having PositionInText=rvpitAboveText
9.Main document's text boxes and sidenotes having PositionInText=rvpitBelowText
10.Main document, including footnotes and endnotes
11.Main document's text boxes and sidenotes having PositionInText=rvpitAboveText
Text boxes and sidenotes are drawn in the order of their positions in the parent document.
▪RichViewAlternativePicPrint typed constant;
▪RichViewPixelsPerInch typed constant.