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

Report to printer

edited September 2004 in Devices
Hi,
I'm trying ReportBuilder Enterprise 7.01 with Delphi 6 in Windows 98 and
Windows XP and I need to know if is possible do the following:
I need that when I choose properties - page layout in the print dialog, it
shows the papername that the printer has configured and not the papername
that has configured the ppReport.

Thanks,

Marina

Comments

  • edited September 2004

    A report layout is designed for a specific paper size as specified by the
    Report.PrinterSetup properties. These properties are applied to the printer
    when the report prints.

    The article below explains how to get the Windows default printer name and
    paper size. You can then apply these to the report.PrinterSetup property
    prior to calling Report.Print.



    --------------------------------------------------
    Tech Tip: Windows Default Printer Settings
    ---------------------------------------------------

    1. Default Printer Name

    You can get the name of the computers default
    printer by accessing ReportBuilder's global
    printer list object - ppPrinters.


    uses
    ppPrintr;


    var
    lsPrinterName: String

    begin

    lsPrintername := ppPrinters.DefaultPrinterName;

    end;



    2. Default Printer Setup


    Place the following code in the OnClick event-handler
    of a button on a form. When the button is pressed
    a message will be displayed showing the default
    printer name and paper size.

    You can get the other document defaults via
    the TppPrinter.PrinterSetup properties.


    uses
    ppPrintr;

    var
    lPrinter: TppPrinter;

    begin

    lPrinter := TppPrinter.Create;

    lPrinter.PrinterName := ppPrinters.DefaultPrinterName;

    ShowMessage(ppPrinters.DefaultPrinterName + ': ' +
    lPrinter.PrinterSetup.PaperName);

    {assign default printer settings to a report}
    myReport.PrinterSetup := lPrinter.PrinterSetup;


    lPrinter.Free;

    end;


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




    --
    Nard Moseley
    Digital Metaphors Corporation
    www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited September 2004
    Thanks for your answer, it's very useful if I print in the default printer,
    but if when the print dialog appears I choose other printer (diferent to the
    default printer), I need that it takes the paper size that is configurated
    in the printer and not the paper size from the report.

    This is not a mine ocurrence, it's a needed of users of my program, because
    they usually have a matrix printer and an ink printer. Sometimes they print
    the reports in the matrix and sometimes in the ink. Obviouslly the printers
    use diferent paper sizes.

    Was I clear?

    Marina

  • edited September 2004

    1. Try using the Report.OnPrintDialogClose event to determine what printer
    was chosen. Here is an example:

    uses
    ppPrintr;

    procedure TForm1.ppReport1PrintDialogClose(Sender: TObject);
    var lPrinter: TppPrinter;
    begin
    if ppReport1.PrintDialog.ModalResult = mrOk then
    begin
    lPrinter := TppPrinter(ppReport1.PrintDialog.Printer);
    ShowMessage(lPrinter.PrinterSetup.PrinterName);

    lPrinter.PrinterSetup.PaperName :=
    GetDefaultPaperName(lPrinter.PrinterSetup.PrinterName); // see function
    below

    end;
    end;

    2. Then to the above, add a call to a function that determines the default
    paper name. Something like this:

    function GetDefaultPaperName(aPrinterName: String): String;
    var lPrinter: TppPrinter;
    begin
    lPrinter := TppPrinter.Create;
    lPrinter.PrinterName := aPrinterName;

    Result := lPrinter.PrinterSetup.PaperName;

    lPrinter.Free;


    end;



    --
    Nard Moseley
    Digital Metaphors Corporation
    www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.