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:

    1. do you have BeforeExport and / or BeginExport Events declared for "frxpdf"?
    2. are all of those lines in your source example in the one place and "as is" (or did you omit stuff)?
    3. are there any other bits of code changing settings on "frxpdf" or have you changed the default settings in "Object Inspector"?
    4. how do you specify the "default" path for storage of the PDF File exported?

    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?

  • PolomintPolomint Australia
    edited December 2022

    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 🤞🤞

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.