As you may know in ReportBuilder, a report is separated into numerous page objects. Each page object contains a list of DrawCommand objects which are sent to the output device (Screen, Printer, File) and interpreted to render graphics, text, etc.
When adding a watermark in code, you are essentially inserting your own DrawCommand to the beginning of the list so it is rendered before any others.
If you already have code that creates watermark DrawCommand(s), it should be fairly simple to reuse it and simply add them to the page before any other drawcommands are rendered. Another option is to simply use Page Layers and create your watermark in the designer.
See the following example on how this should be done. Note that in the example the EndPage event is used to add the watermark so it will appear in front of all other drawcommands (for our demo). In most cases you will want your watermark behind other controls so you will want to create a page layer and use its BeforePrint event.
Comments
As you may know in ReportBuilder, a report is separated into numerous
page objects. Each page object contains a list of DrawCommand objects
which are sent to the output device (Screen, Printer, File) and
interpreted to render graphics, text, etc.
When adding a watermark in code, you are essentially inserting your own
DrawCommand to the beginning of the list so it is rendered before any
others.
If you already have code that creates watermark DrawCommand(s), it
should be fairly simple to reuse it and simply add them to the page
before any other drawcommands are rendered. Another option is to simply
use Page Layers and create your watermark in the designer.
See the following example on how this should be done. Note that in the
example the EndPage event is used to add the watermark so it will appear
in front of all other drawcommands (for our demo). In most cases you
will want your watermark behind other controls so you will want to
create a page layer and use its BeforePrint event.
http://www.digital-metaphors.com/rbWiki/Delphi_Code/Formatting/How_To...Manually_Add_a_Watermark_to_a_Page
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
are there any code-snippets how to create a pagelayer on runtime in
code?
TIA Carsten
Nico Cizik (Digital Metaphors) formulierte Montag :
A complete example of how to create a report in code is located in the
Developer's Guide. Below is a quick snip of creating a band in code.
uses
ppBands;
FPageStyle: TppPageStyle;
begin
FPageStyle := TppPageStyle.Create(Self);
FPageStyle.Report := ppReport;
FPageStyle.OnBeforePrint := ehPageStyle_BeforePrint;
end;
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
I will change my code from report.onendpage to pagestyle.onbeforeprint
Thanks!
Am 04.08.2015 um 18:49 schrieb Nico Cizik (Digital Metaphors):
it is BeforePrint instead of OnBeforePrint!
FPageStyle.BeforePrint := ehPageStyle_BeforePrint;
Nico Cizik (Digital Metaphors) schrieb am 04.08.2015 :