rbWiki > Output > Archive > How To...Add a Drawcommand to a Page

How To...Add a Drawcommand to a Page

Table of contents
  1. 1. Question 
  2. 2. Solution

Question 

"How do I add items to an archived page before viewing or printing with the Archive Reader?" 

Solution

Create a generic TppRasterDevice and implement its OnPageReceive event to add a drawcommand to the page before the report is rendered.

Download: ArchiveReaderAddDrawCommand.zip

Sample Delphi code:

procedure TForm1.ppArchiveReader1BeforePrint(Sender: TObject);
var
  lRasterDevice: TppRasterDevice;
begin

  // get reference to the screen or printer device
  if (ppArchiveReader1.PrinterDevice <> nil) then
    lRasterDevice :=  ppArchiveReader1.PrinterDevice
  else if (ppArchiveReader1.PreviewForm <> nil) then
     lRasterDevice :=  TppViewer(ppArchiveReader1.PreviewForm.Viewer).ScreenDevice
  else
    lRasterDevice := nil;

  // attach handler to device OnPageReceive event
  if (lRasterDevice <> nil) then
    lRasterDevice.OnPageReceive := ehPageReceive;

end;


procedure TForm1.ehPageReceive(Sender, aPage: TObject);
begin
  // add draw command to page (see example for implementation
  AddDrawCommand(TppPage(aPage));

end;
Tags
none

Files (0)

 
You must login to post a comment.