Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

ppArchiveReader

edited June 2006 in General
All

I have a routine which loads an invoice image from an raf file (saved in a
database) and this displays/prints in the Archive Reader.

One of my customers want to print a caption 'COPY INVOICE' onto this.

Is there any way to achieve this?

Thanks in advance.

Philip L Jackson

Comments

  • edited June 2006
    Hi Philip,

    An archive file is meant to be a snapshot of a report that has already been
    generated. It is possible to manually add a drawcommand into the page
    object before the page is generated using the Device.OnPageReceive event.
    You will need to implement this event for the device being used in order to
    accomplish what you need.

    ppArchiveReader.PrinterDevice.OnPageReceive

    TppViewer(ppArchiveReader.PreviewForm.Viewer).ScreenDevice.OnPageReceive

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited August 2006
    Hi Nico

    Sorry to be thick but I have tried to understand this a couple of times.

    How do you mean "implement this event", what does the draw command look
    like.

    Could you be a little more explicit with your example?

    By the way the archive is great, when printing a copy invoice I get exactly
    what was printed first time, however for tax purposes, I need to mark the
    copy as 'This is a certified copy of the original invoice'

    Thanks in advance

    Philip L Jackson

  • edited August 2006
    Hi Philip,

    Take a look at the following example that adds a drawtext command to an
    archive file.

    http://www.digital-metaphors.com/tips/AddDrawCommandToArchive.zip


    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited August 2006
    Hi Nico

    Thanks for the sample project it has been of great help - I now have a
    nearly working solution.

    Further issues are :-

    1. On the first form I have a ppViewer and assign the archive reader to
    this using the code

    ppviewer1.report := ppArchiveReader1;
    ppViewer1.RegenerateReport;

    the text is only displayed when I print the document, not when I display
    it in the viewer. Can this be changed to display and print?

    2. If I print to File i.e. PDF then I do not get the text, only when I
    print to a printer.

    Thanks for your help.

    Regards

    Philip L Jackson



  • edited August 2006
    Hi Philip,

    As you probably noticed in the example I only implemented the OnPageReceive
    event of the printer device and screen device. This is the reason the text
    does not show up when using the PDF or Archive devices. You will also need
    to implement these events if you would like to see the text.

    example...

    uses
    ppPDFDevice;

    ---

    var
    lPDFDevice: TppPDFDevice;
    begin

    lPDFDevice := TppPDFDevice.Create;
    lPDFDevice.Publisher := ppReport1.Publisher;
    lPDFDevice.OnPageReceive := PageReceiveEvent;

    ppReport1.PrintToDevices;
    end;

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited August 2006
    Hi Nico

    I can see from your example how to control this if I always wanted a pdf
    file but I am using the Print Dialog option PrintToFile and can not see
    where this would fit in with the following :-

    lsName :=
    winInvCopy.InvoiceTable.FieldByName('INVOICE_NO').AsString;
    MyCopies := StrToInt(edtCopies.Text); //this may be
    changed after 1st print by Print Dialog

    if (lsName <> '') then
    begin
    DBArchiveReader.DatabaseSettings.Name := lsName;
    ppViewer1.Print;
    end;
    Thanks for your patience.

    Philip L Jackson


  • edited August 2006
    Hi Philip,

    Since you are using your own TppViewer object, you will need to implement
    its ScreenDevice.OnPageReceive event instead of the previewer's. For
    instance, in the example, you would say...

    ppViewer1.ScreenDevice.OnPageReceive := PageReceiveEvent.

    This will allow the text to show up in your viewer.

    When using the Print Dialog, you will need to determine the filetype a
    person has selected perhaps using the OnPrintDialogClose event and checkin
    the PrintDialog.DeviceType property. Once you know what device they are
    using (i.e. PDF, Printer, etc.), you can use the TppReport.FileDevice
    property to access that device and assign its OnPageReceive event.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.