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

Margins are specified in Margins property.

Margins in TRVPrint

Margins in TRVPrint

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

Margins are measured in Units (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

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)

Headers are assigned using SetHeader, footers are assigned using SetFooter methods.

Any TRichView document can be assigned as a header or footer. Positions of headers and footers are defined by HeaderY and FooterY.

Header and Footer

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

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;

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.

Incremental printing

You can define the range of items to print, using MinPrintedItemNo and MaxPrintedItemNo properties. If these properties define a subrange of items, only this subrange (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.

Order of drawing

The component draws a page content in the following order:

1.page background

2.OnPagePrepaint event

3.Header's text boxes and sidenotes having PositionInText=rvpitBelowText

4.Header

5.Header's text boxes and sidenotes having PositionInText=rvpitAboveText

6.Footer's text boxes and sidenotes having PositionInText=rvpitBelowText

7.Footer

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

12.OnPagePostPaint event

Text boxes and sidenotes are drawn in the order of their positions in the parent document.

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\


TRichView © trichview.com