Default file name exporting report to PDF etc
Using FR6 I am setting the filename before exporting the report.
The dialog appears when exporting but the save as dialog shows the filename as a GUID instead of the filename specified.
Is there a way to fix this?
frxpdf.FileName := 'MyFile.PDF';
frxpdf.ShowDialog := pdialog;
frReport.Export(frxPDF);
Comments
G'day Tony,
Assuming that your "frxpdf" is an instance of TfrxPDFexport, and "pdialog" is a Boolean variable / constant, then that should have worked. We have something similar in our Projects (which were converted from FR VCL 6 a while ago).
A couple of questions:
The issue of the GUID puzzles me. I'll think about it "off line" and come back if anything occurs to me...
Cheers, Paul
PS clicking the "export to PDF" button on the Preview Form in our Debug set-up shows (in succession) these screenshots:
P,
Hi Paul
Many thanks for the detailed reply. You nailed it with Q4
It caused me to create a trivial test project (should have done before posting!) which worked fine.
The error was in my code assigning the filename (the guid was my doing - geez)
Cheers
Tony
(Noosa Heads)
No worries Tony. It can be a bit hot and steamy in Noosa at this time of the year!
Cheers, Paul
Hi Paul,
Do you create TfrxPDFexport each time you print a report and set FileName property or threre is a global one object?
G'day,
The instance of TfrxPDFexport was dropped on a Form that is created once (when the App starts), and yes it is "global", so shared by all of the App's Reports.
Cheers, Paul
PS we use a lot of "common code" to make it very easy to create / maintain Reports. 🤓
Ok.
Do you know if it is possible to set the PDF filename using pascal script inside the report?
The user can customize the report and asked me how to change the default filename when exporting
G'day,
I haven't tried this, but strongly suspect you will have a scope / visibility problem. I don't know how you can access objects declared the Delphi / C++ code from Pascal Script.
We do use a small amount of Pascal Script with Variables initialised in the Delphi Report Unit, but I've never tried going back the other way.
I'll play a bit with this in a Test-bed later...
Cheers, Paul
Hi,
I use a variable to set the custom filename when exporting a report to PDF to send an email. After preparing the report, I get the variable value in Delphi and set the TfrxPDFexport filename property.
But, when user is viewing the report (preview), I can't intercept the exporting action to change the filename.
G'day,
OK so can you "reuse" your existing code in Delphi (to get the variable value) in the TfrxPDFexport Event OnBeginExport?
<code>
with frxPDFexport do begin
:
FileName := <yourFRvariablevalue>;
:
end;
</code>
We use both OnBeforeExport and OnBeginExport to manage other settings (e.g. PDF preferences) so I am pretty confident this should work!
Cheers, Paul 🤞🤞