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

Exporting Report to file

edited February 2003 in General
Hello I have activated the AllowPrintToFile property, but I'd like to remove
some items form the the list displayed, in the combobox , on the print
dialog,
Is there a way to do it?

Thanks in advance

Marco

Comments

  • edited February 2003
    -----------------------------------------------------
    Tech Tip: Controlling Available Print To File formats
    -----------------------------------------------------

    How can I limit which file formats are displayed by
    the print dialog?


    Formats can be registered and unregistered via code.

    Example:


    uses
    ppDevice;



    {add some file formats}

    ppRegisterDevice(TppTextFileDevice);
    ppRegisterDevice(TppReportTextFileDevice);
    ppRegisterDevice(TppArchiveDevice);



    {remove some file formats}

    ppUnRegisterDevice(TppTextFileDevice);
    ppUnRegisterDevice(TppReportTextFileDevice);
    ppUnRegisterDevice(TppArchiveDevice);


    --
    Tech Support mailto:support@digital-metaphors.com
    Digital Metaphors http://www.digital-metaphors.com






    --
    Nard Moseley
    Digital Metaphors
    http://www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited February 2003


    Ok it's fine. But I have another problem... I want to set the default for
    the printdialog, I have tried to set the properties AllowPrintToFile and
    DiveceType and TextFileName
    when the print dialog is created, but it has no effect. I can't set them
    before becouse I want the preview. I also have tryied to set them when the
    print dialog is closed, but the printig is always direct to printer.
    How can I manage it?
    Thanks
    marco
  • edited February 2003
    I've also tryied to use ppviewer, but the checkbox on print dialog is still
    unabled.
  • edited February 2003

    "Marco Cotroneo" ha scritto nel messaggio
  • edited February 2003
    Setting Report.PrintDialog.PrintToFile to true in the OnPrintDialogCreate
    event does not work, even if the properties for AllowPrintToFile is set,
    because the device is not set to one of the file devices. You can modify the
    RBuilder\Demos\EndUser\ReportExplorer example to do this as shown below:


    {---------------------------------------------------------------------------
    }
    { TmyEndUserSolution.LoadEndEvent }

    procedure TmyEndUserSolution.LoadEndEvent(Sender: TObject);
    begin
    ppReport1.OnPreviewFormCreate := PreviewFormCreateEvent;
    ppReport1.OnPrintDialogCreate := PrintDialogCreateEvent;
    end; {procedure, LoadEndEvent}


    {---------------------------------------------------------------------------
    }
    { TmyEndUserSolution.PrintDialogCreateEvent }

    procedure TmyEndUserSolution.PrintDialogCreateEvent(Sender: TObject);
    begin

    ppReport1.PrintDialog.AllowPrintToFile := True;
    ppReport1.PrintDialog.TextFileName := 'c:\myReport.txt';
    ppReport1.PrintDialog.DeviceType := dtReportTextFile;

    end;



    --
    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited February 2003
    Thanks but I found out another way... I cast the dialog to TppPrintDialog
    on then PrintDialogCreate, in this way I can do other operation. Could it
    give me any problem?

    TppPrintDialog(ppReportBase.PrintDialog).cbxPrintToFile.Checked :=
    ppReportBase.AllowPrintToFile;

    if TppPrintDialog(ppReportBase.PrintDialog).cbxPrintToFile.Checked then
    begin

    TppPrintDialog(ppReportBase.PrintDialog).cbxPrintToFile.Visible :=
    false;
    TppPrintDialog(ppReportBase.PrintDialog).lblPrintToFile.Visible :=
    false;
    TppPrintDialog(ppReportBase.PrintDialog).pnlPrint.Visible := false;
    TppPrintDialog(ppReportBase.PrintDialog).pnlPrintToFile.Visible := true;
    // // TppPrintDialog(ppReportBase.PrintDialog).pnlBottom.Align:=
    alNone;
    // TppPrintDialog(ppReportBase.PrintDialog).pnlBottom.Align :=
    alBottom;
    // TppPrintDialog(ppReportBase.PrintDialog).pnlBottom.Align := alTop;
    TppPrintDialog(ppReportBase.PrintDialog).AutoSize := true;
    end;
    Thanks
    Marco
  • edited February 2003
    If you want to typecast it, that should work too. However, if you ever want
    to replace the print dialog (all forms in RB are replacable) then you will
    have to change the form class you are typecasting with.


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.