[Demos] Headers and Footers

Demos, code samples. Only questions related to the existing topics are allowed here.
Post Reply
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

[Demos] Headers and Footers

Post by Sergey Tkachenko »

:?: Hi, Is it possible with TRichView 1.9.8 to include Page Header and PageFooter?
And how?
Yes and no.

It's possible to make any kind of header and footer, but they must be implemented differently depending on your needs.

The component supports complex headers and footers - they can be multiline, contain images, tables, etc.
They must be assigned to TRVPrint component by the methods SetHeader and SetFooter.
See the example Demos\Delphi\Assorted\Printing\Headers\
There is a limitation of this method - the same header and footer for all pages, with no dynamic fields (like page number).

Update 2014-Sep-05: TRichView v15 implements special headers and footers for the first page and odd/even pages, as well as page number and page count fields.

If you need different headers for different pages, you need to draw them yourself, using OnPagePrepaint event.
This demo shows how to draw a simple text as a header:
Demos\Delphi\Assorted\Printing\Printing\
Since you draw this text yourself, you can draw as many lines as you want.

RichViewActions ( http://www.trichview.com/resources/actions/ ) process this event themselves and draw one plain text line. But they are limited with one line. They understand several codes like page number and pages count.

If you need to draw more complex headers (different for different pages),
you can use TRVReportHelper component for this:
http://www.trichview.com/support/files/printheader.zip
This demo uses TRVReportHelper to draw header in TRVPrint.OnPagePrepaint event.
This demo draws the same header for all pages, but can be easily changed to draw different ones.

How it can be done is shown in this demo
http://www.trichview.com/support/files/cppheader.zip , but it's for
C++Builder.

And the last demo - using TRVReportHelper for drawing both header/footer and the main document:
a4.zip
(4.46 KiB) Downloaded 4117 times
It draws the result on the metafile, but can be easily changed to draw on
the printer canvas.
Last edited by Sergey Tkachenko on Fri Sep 05, 2014 3:50 pm, edited 2 times in total.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

The most complex case:
- headers are complex documents;
- headers have different heights on different pages.
http://www.trichview.com/support/files/ ... aderex.zip

This demo is updated 2007-May-24. Fix: when drawing preview, printer-compatible Canvas must be used for calling rvhHeader.Init (instead of the print preview window Canvas)
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: [Demos] Headers and Footers

Post by Sergey Tkachenko »

Since TRichView 17, the following improvements are added:
- TRVPrint component can be used not only for printing, but also for drawing pages on any canvas. Unlike TRVReportHelper, TRVPrint supports page layout properties, header and footers, footnotes, endnotes and text boxes.
- new helper class TRVReportHelperWithHeaderFooter. It contains TRVReportHelper components representing documents with all possible headers and footers, linked to their RVStyles. It is useful for loading RTF or RVF files containing headers and footers.
- new demo projects using the features above to generate PDF using third-party libraries (in ThirdParty\Export folder).
Post Reply