Output to Stream
In your reports demo 109 where you show how to do this you delete the file
first. Why is this necessary if it is being output to a stream? Also will
the call to ppReport1.PrintTo Devices only print to the stream?
Ken
1.. procedure TPDFFrm.btnGenerateClick(Sender: TObject);
2.. var
3.. lPDFDevice: TppPDFDevice;
4.. begin
5..
6.. // delete existing file
7.. if FileExists(ppReport1.TextFileName) then
8.. DeleteFile(ppReport1.TextFileName);
9..
10..
11.. // creat and configure the PDFDevice
12.. lPDFDevice := TppPDFDevice.Create(nil);
13..
14.. if (FOutputStream = nil) then
15.. FOutputStream := TMemoryStream.Create
16.. else
17.. FOutputStream.Clear;
18..
19.. try
20.. lPDFDevice.PDFSettings := ppReport1.PDFSettings;
21.. lPDFDevice.OutputStream := FOutputStream; // assign output
stream
22.. lPDFDevice.Publisher := ppReport1.Publisher;
23..
24.. // generate the report
25.. ppReport1.PrintToDevices;
26..
27.. btnSaveToFile.Enabled := True;
28..
29.. finally
30.. lPDFDevice.Free;
31.. end;
32..
33.. end;
__________ Information from ESET NOD32 Antivirus, version of virus signature database 5628 (20101118) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
first. Why is this necessary if it is being output to a stream? Also will
the call to ppReport1.PrintTo Devices only print to the stream?
Ken
1.. procedure TPDFFrm.btnGenerateClick(Sender: TObject);
2.. var
3.. lPDFDevice: TppPDFDevice;
4.. begin
5..
6.. // delete existing file
7.. if FileExists(ppReport1.TextFileName) then
8.. DeleteFile(ppReport1.TextFileName);
9..
10..
11.. // creat and configure the PDFDevice
12.. lPDFDevice := TppPDFDevice.Create(nil);
13..
14.. if (FOutputStream = nil) then
15.. FOutputStream := TMemoryStream.Create
16.. else
17.. FOutputStream.Clear;
18..
19.. try
20.. lPDFDevice.PDFSettings := ppReport1.PDFSettings;
21.. lPDFDevice.OutputStream := FOutputStream; // assign output
stream
22.. lPDFDevice.Publisher := ppReport1.Publisher;
23..
24.. // generate the report
25.. ppReport1.PrintToDevices;
26..
27.. btnSaveToFile.Enabled := True;
28..
29.. finally
30.. lPDFDevice.Free;
31.. end;
32..
33.. end;
__________ Information from ESET NOD32 Antivirus, version of virus signature database 5628 (20101118) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
This discussion has been closed.
Comments
I believe the demo exports the report to stream, then saves it to file to
show that the stream data is valid. We delete any existing files in case
one of the previous buttons was pressed to start with a clean slate.
Making a call to PrintToDevice will print/export with each device that has
the same publisher as the report. Exporting to stream is controlled only by
the re-assigning of the OutputStream property.
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com