How to handle header and footers

General TRichView support forum. Please post your questions here
Post Reply
Klaus Kirchhoff

How to handle header and footers

Post by Klaus Kirchhoff »

I want to include haeder (more then one line) in a dokument is the possible?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Oops, I missed this question, sorry.

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).

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.

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.

This demo shows how it can be done:
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:
http://www.trichview.com/support/files/a4.zip
It draws the result on the metafile, but can be easily changed to draw on the printer canvas.
Post Reply