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

PrintDialogCreate and settings!

edited February 2009 in General
Hi, I have a problem with print settings...
On an anchestor form, i have code like this:

procedure XXXXXX.reportPrintDialogCreate(Sender: TObject);
Begin
if CONDITION then begin
(Sender as TppReport).PrinterSetup.Copies := 1 ;
(Sender as TppReport).AllowPrintToFile := True;
(Sender as TppReport).PrintDialog.PrintToFile := True;
(Sender as TppReport).PrintDialog.DeviceType := dtPDF ;
(Sender as TppReport).PrintDialog.TextFileName :=
IncludeTrailingBackSlash( ......... FILENAME ETC )
end;
end;

shortly, if a condition is true, I'll automatically set the report to print
to defined PDF file.

but Sometimes, the user can deselect the "Print to file" check, and decide
send report to a printer.
here we have the problem: even if i uncheck the print to file oprtion, the
report will generate the given file name.... if I clear the filename field
and uncheck the options, the report will generate an error "file name not
exists"...

it seems that ignore some end-user options....

nb: RB 11.02 on Delphi 7.

thanks

Comments

  • edited February 2009
    Hi,

    For future reference, please use your real name when posting to these
    newsgroups.

    This is most likely a timing issue. Instead of assigning the properties of
    the actual print dialog, try assigning the report properties before making a
    call to Report.Print.

    Report.PrinterSetup.Copies := 1;
    Report.AllowPrintToFile := True;
    Report.ShowPrintDialog := True;
    Report.DeviceType := 'PDF';
    Report.TextFileName := FileName;

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2009
    Thanks for the response.

    I'm sorry but a have to do it in an anchestor form.... it's a application
    global settings....
    and i need to see the preview before decide to create pdf file or print
    report. so i can't set this proerties before print method :(




  • edited March 2009
    Hi,

    Once again, please use your real name when posting to these newsgroups.

    I now see the limitation you have. Upon further research, you need to
    remove the following line from your code below.

    (Sender as TppReport).PrintDialog.PrintToFile := True;

    This should fix the issue.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2009
    I hope now i changed the name successiful..

    but i have leave the line, the print dialog don't propose me to save to pdf
    file. :(



  • edited March 2009
    Hi Diego,

    In my quick testing with RB 11.03, setting the following properties
    automatically checked the Print To File option and allowed me to print to a
    printer if it was unchecked.

    procedure TForm1.ppReport1PrintDialogCreate(Sender: TObject);
    begin
    ppReport1.PrintDialog.AllowPrintToFile := True;
    ppReport1.PrintDialog.DeviceType := 'PDF';
    ppReport1.PrintDialog.TextFileName := 'c:\MyReport.pdf';
    end;

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2009
    I have 11.02.

    I'll upgrade as soon as possible and try.

    thanks.

This discussion has been closed.