rvico TRichView Reference | TRVPrint

RVPRINT TRVPrint

Properties   Methods   Events

Top  Previous  Next

This component allows printing TRichView, TRichViewEdit, TDBRichView, or TDBRichViewEdit. It is Invisible at run-time.

Unit PtblRV;

Syntax

TRVPrint = class(TCustomRVPrint)

Hierarchy

TObject

TPersistent

TComponent

TCustomRVPrint

How to Use

1.Assign the source component for printing (AssignSource method).
2.(optionally) Assign header and/or footer (SetHeader, SetFooter).
3.Format pages (FormatPages method).
4.Now you can:
get a number of pages (PagesCount property);
display a print preview (using TRVPrintPreview component; see also DrawPreview, MakePreview MakeScaledPreview methods);
print the whole document (Print method) or range of pages (PrintPages method).
5.When finished, you can release some temporally allocated memory (Clear).

Events

You can display some information about the process of repaginating and printing:

OnFormatting occurs during repaginating (FormatPages method);
OnSendingToPrinter occurs during printing (Print and PrintPages methods).

You can draw additional content using the following events:

OnPagePrepaint and OnPagePostpaint allow to draw on each page below/over TRichView document;
OnPrintComponent requests image of inserted control for printing.

Margins

There are four properties: LeftMarginMM RightMarginMM, TopMarginMM,BottomMarginMM.

MARGINS

This picture illustrates the meaning of margin properties. Paragraph indents are not shown for simplification.

LeftMarginMM, RighMarginMM, TopMarginMM, BottomMarginMM are measured in millimeters (shown in red).

TRichView.LeftMargin, TRichView.RightMargin, TRichView.TopMargin and TRichView.BottomMargin are measured in "screen pixels" (they are recalculated according to the printer resolution, and margins on the page look like margins on the screen; shown in blue).

Left and right margins can be swapped for even pages, if MirrorMargins is set to True.

See also ClipMargins property.

Headers and Footers

The current implementation of headers and footers is preliminary. It allows to print the same header and footer on all pages. Any RichView document can be assigned as a header or footer. Positions of header and footer are defined by HeaderYMM and FooterYMM.

HANDF

If header and/or footer is too long, size of the main document is adjusted to avoid overlapping:

HANDF2

If you want different header / footer for different pages, consider:

printing document in several parts, each of them with its own header/footer;
using OnPagePrepaint event;
using TRVReportHelper.

See also: GetHeaderRect, GetFooterRect.

Document inside RVPrint

RVPrint contains an instance of TPrintableRV (descendant of TRichView) inside. This variable (named rv) is public and you can change some properties of it:

Color,
BackgroundStyle,
BackgroundBitmap.

Changing other its properties is not recommended.

Example:

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 source RichView is not destroyed while you are printing.

Tips and Tricks

See http://www.trichview.com/forums/viewtopic.php?p=250.

See Also

See also:

UpdatePaletteInfo method;
TRichView.PageBreaksBeforeItems;
TRichView.AssignSoftPageBreaks;
TRVReportHelper components;
RichViewAlternativePicPrint typed constant;
RichViewPixelsPerInch typed constant.

Demo projects:

Demos\Delphi\Assorted\Printing\
Demos\CBuilder\Assorted\Printing\


RichView © Sergey Tkachenko