Adding a watermark to an archive reader
Hello,
A while ago i've send a question about printing a watermark on a raf file
using the archive reader. I got the answer that is would be possible using
the TppDevice.OnPageReceive event ta add it. I should use the OnBeforePrint
event to add this event.
I can't get it to work. I've tried to add an AddWatermark event to the
BeforePrint event of the ArchiveReader but this doesn't seem to work.
How can i ust this OnPageReceive event when printing a PDF file using
ExtraDevice? I've looked at the ppViewer.pas file, where the example is
located but this doesn't help me very much. I need the TppPage class to add
a tppdrawtext class but where can i get it, and can i use the tppdrawimage
class instead?
thanks in advance.
Wim Looman.
A while ago i've send a question about printing a watermark on a raf file
using the archive reader. I got the answer that is would be possible using
the TppDevice.OnPageReceive event ta add it. I should use the OnBeforePrint
event to add this event.
I can't get it to work. I've tried to add an AddWatermark event to the
BeforePrint event of the ArchiveReader but this doesn't seem to work.
How can i ust this OnPageReceive event when printing a PDF file using
ExtraDevice? I've looked at the ppViewer.pas file, where the example is
located but this doesn't help me very much. I need the TppPage class to add
a tppdrawtext class but where can i get it, and can i use the tppdrawimage
class instead?
thanks in advance.
Wim Looman.
This discussion has been closed.
Comments
1. Inside the beforeprint event you just need to assign the OnPageReceive
event of the device you are using. Then inside that event you create a
drawcommand and add it to the page. AddWatermark is not an event, it is
simply a routine that adds a drawcommand to a page at runtime.
- I coded a quick example on how to add a text drawcommand (watermark) to
the screen and printer device. The same concept should apply for any
device. The code snip is below and should get you on the right track.
2. We are not familiar with the ExtraDevices source. I can only comment on
how the native RB devices function. All ExtraDevices questions should be
directed to Waler's support.
Code Snip...
--------------
uses
ppViewr, ppDevice, ppDrwCmd;
procedure TForm1.CreateWaterMark(aPage: TObject);
var
lWaterMark: TppDrawText;
lPage: TppPage;
begin
lPage := TppPage(aPage);
lWaterMark := TppDrawText.Create(Self);
lWaterMark.Text := 'Watermark';
lWaterMark.Font.Name := 'Arial';
lWaterMark.Font.Size := 18;
lWaterMark.Font.Color := clBlack;
lWaterMark.Top := ppArchiveReader1.PrinterSetup.PageDef.mmPrintableHeight
div 2;
lWaterMark.Left := ppArchiveReader1.PrinterSetup.PageDef.mmPrintableWidth
div 2;
lWaterMark.Height := 10000; //rough estimate
lWaterMark.Width := 100000; //rough estimate
lWaterMark.Page := lPage;
end;
procedure TForm1.ppArchiveReader1BeforePrint(Sender: TObject);
begin
if ppArchiveReader1.PreviewForm <> nil then
TppViewer(ppArchiveReader1.PreviewForm.Viewer).ScreenDevice.OnPageReceive
:= ScreenPageReceive;
if ppArchiveReader1.PrinterDevice <> nil then
ppArchiveReader1.PrinterDevice.OnPageReceive := PrinterPageReceive;
end;
procedure TForm1.PrinterPageReceive(Sender, aPage: TObject);
begin
CreateWaterMark(aPage);
end;
procedure TForm1.ScreenPageReceive(Sender, aPage: TObject);
begin
CreateWaterMark(aPage);
end;
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thanks, works great.
Wim.