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

PrintToDevices Question

edited July 2009 in Devices
Once a report is generated I want to be able to give a user the option to
store a PDF of the report to a database via a memory stream. However using
the following code:

MS:=TMemoryStream.Create;
lPDFDevice:=TppPDFDevice.Create(nil);
lPDFDevice.PDFSettings.Subject:=Subject;
lPDFDevice.PDFSettings.Title:=Subject;
lPDFDevice.OutputStream:=MS;
lPDFDevice.Publisher:=repQuotation.Publisher;
repQuotation.PrintToDevices;
lPDFDevice.Free;
...

results in it being printed as well as the repQuotation.DeviceType is
dtPrinter.

How can I jest output to the memory stream.

Many thanks,

Ken

Comments

  • edited July 2009

    Here is an rbWiki article that shows how to generate to Printer and PDF at
    the same time...

    http://www.digital-metaphors.com/rbWiki/Output/Printer/How_To...Print_to_the_Printer_and_File_Device


    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited July 2009
    Thanks Nard but is there a way to do it the way I asked?

    Ken

  • edited July 2009

    Try adding some code to disconnect the printer device...


    try
    if myReport.PrinterDevice <> nil then
    myReport.PrinterDevice.Publisher := nil;

    // generate to PDF


    finally
    if myReport.PrinterDevice <> nil then
    myReport.PrinterDevice.Publisher := myReport.Publisher;

    end;


    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited August 2009
    Nard,

    Sorry, but I need to revisit this.

    When a report is open and a user clicks on print, after printing I want to
    also get the PDF printed to a stream. Whatever I try to do when I call
    PrintToDevices I end up with the report being physically printed again to
    the printer.

    Any help greatly appreciated.

    Ken

This discussion has been closed.