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

Print to pdf-file without a preview

Hello,

Somehow, my reports keep showing up in the default browser after I print them.
How can I prevent this?

I create a report-component runtime, load the layout from the database, and set the following properties:

rep.PrinterSetup.DocumentName := AReportName;
rep.PrinterSetup.BinName := 'Default';
rep.ShowCancelDialog := False ;
rep.AllowPrintToFile := true ;
rep.TextFileName := AFileName;
rep.ShowPrintDialog := False;
rep.DeviceType := PDF;

After calling rep.print the file is always opened in Google Chrome.

How can I prevent this?

btw: The "openfile" property of the loaded layout is "False"

kind regards,

Dirk Janssens.

Comments

  • Hi Dirk,

    Try placing a breakpoint in the TppFileDevice.EndJob routine (ppFilDev.pas file line 1187) to see if the OpenFile property is indeed False.

    This is the only place an exported file will be automatically opened. If it is not executed, the issue is not with RB.
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • Thank you!

    The property is indeed "true". I also found the cause in my code:
    After this line :

    rep.XLSSettings.OpenXLSFile := true ;

    The property openfile is changed.
    (rep.openfile = true.)

    I would expect that this property would only effect Excel files, and not the pdf.
    Is this by design?

    kind regards,

    Dirk Janssens.
  • OpenXLSFile is deprecated and only retained for backward compatibility. I suggest searching your code for any use of OpenXLSFile or OpenPDFFile and replacing with the Report.OpenFile property.
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
Sign In or Register to comment.