PrintToDevices Question
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
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
This discussion has been closed.
Comments
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
Ken
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
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