Print Preview in FireMonkey

TRichView 19.4 – printing in FireMonkey version

TRichView is updated to version 19.4.

The new release includes the second version for FireMonkey (still Windows platform only).

Trial versions are available: https://www.trichview.com/download/
A full version can be found in the protected section of this forum (or old setups can check for updates and download new versions).

New in this update (in FireMonkey version):

  • printing and print preview
  • justify alignment
  • zooming
  • IME input (for East Asian languages)

Printing for FireMonkey

The following components are ported to FireMonkey in this update:
TRVPrint – component for printing TRichView document
TRVReportHelper – component for drawing TRichView document on the specified canvas (for example, in TBitmap or a printer)
TRVPrintPreview – print preview component.

In FireMonkey, TRVPrintPreview is the most tricky component, because screen and printer may use different canvas types (In Windows, it is Direct2D canvas on the screen, and GDI+ canvas for printing). TRVPrintPreview must be able to use the both canvases.

Instead of Color property, FireMonkey version of TRVPrintPreview has Fill: TBrush property, so you can apply a gradient or a textured fill. Page shadow may use a semitransparent color.

Justify alignment

In additional to left, right and center alignments, this update adds “justify” alignment: the text is aligned to the both sides by increasing width of space characters.
Internally, TRichView implements this type of alignment using two completely different algorithms: an universal algorithm (used by GDI+ canvas) and optimized Direct2D algorithm.

The both of them support bi-directional text.

PS: “distributed” alignment (aligning text to the both sides by increasing intercharacter spacing) is still not implemented in FMX, only in VCL and LCL version.

Zooming

In VCL/LCL version, document can be zoomed by specifying the pixel density for drawing in DocumentPixelsPerInch property.

In FireMonkey version, a similar functionality is implemented by ZoomPercent property. By default, it is equal to 100 (meaning 100% zoom). To zoom in/out, assign a new value to this property and call Reformat (or Format).


The example shows how multiresolutional images from TImageList work in TRichView for FireMonkey.
Let we have a TImageList that includes several versions of the same picture for different resolutions:

imagelist.png

Let we insert 16×16 picture:

zoom100.png

Now let’s zoom to 200%:

zoom200.png

As you can see, 32×32 image is used instead of 16×16 image.

How this picture is printed? Let we have 600 dpi printer. 16×16 image will be printed as 100×100. The component chooses the most appropriate available image (64×64) and scales it to 100×100:

printpreview-imagelist.png

IME

An input method (or input method editor, commonly abbreviated IME) allows the user of Latin keyboards to input Chinese, Japanese, Korean and Indic character, as well as special characters like emoticons.

Since this update, FireMonkey version supports IME:


ime.png

Demo projects

The following changes were made in demo projects for FireMonkey:

1) Editors\Editor 2\ demo has additional functionality:
– print and print preview
– button to apply “justify” aligmnent
– combo box to apply zoom (bottom right corner of the demo)

printpreview.png

2) Editors\Notes\ – editor with footnotes and endnotes

3) Assorted\Graphic\ToImage\ shows how to use TRVReportHelper components to make an image from document.

toimage.png


4) Assorted\Printing\Printing\ shows how to print and displays a print preview. The printed document contains images and FMX controls.

5) Assorted\Printing\Headers\ shows how to print a document containing headers and footers (up to 3 headers/footers: for the first page, even pages, other pages)

6) Assorted\Printing\ReportHelper\ shows how to use TRVReportHelper component for printing (to print in one or two columns)

UI translations

The following translation of UI was updated for RichViewActions and ScaleRichView:

  • Thai
Share this article