print

print(win: Frame input): Integer updating;

The print method of the Printer class outputs the frame specified in the win parameter to the printer. The space used by the frame on the printed page is determined by the currently set height of the frame (that is, it can be changed during printing) rather than the height of the frame that was painted during the form definition in the JADE Painter.

An exception is raised if this method is invoked from a server method.

For details about calling the print method when printing a background picture over which is drawn the report itself, see "Layering Print Output", earlier in this section.

Unpredictable results will occur if you mix print and printUnformatted method calls within the same print task.

The Printer category global constants that can be returned by the print method are listed in the following table.

Return Value Global Constant Description
0 Print_Successful The print was successful
15001 Print_Invalid_Control You have attempted to print a control that is not a frame
15002 Print_NewPage_Failed When trying to print a new page, the printer may be off-line or incorrectly configured
15003 Print_Printer_Not_Open You attempted to close a printer that is not currently open
15004 Print_TextOut_Error When trying to print a frame, the printer may be off-line or incorrectly configured
15005 Print_Printer_Open_Failed When trying to print a frame, the printer may be off-line or incorrectly configured
15006 Print_Header_Footer_Too_Large A header or footer frame has exceeded the page depth (height)
15007 Print_Frame_Too_Large You attempted to print a frame that has a depth greater than the page height
15008 Print_Preview_Ignored You attempted to change the printPreview property after printing has begun
15010 Print_Copies_Ignored You attempted to change the copies property after printing has begun
15011 Print_Orientation_Invalid You have assigned a value other than Print_Portrait or Print_Landscape to the orientation property
15013 Print_Currently_Open The specified printer is currently open (that is, the application currently has the printer open)
15014 Print_Failed_To_Obtain_Printer The task failed to obtain the specified printer (that is, the API call to obtain the available printers has failed)
15015 Print_Cancelled The Cancel button on the runtime Print progress dialog was clicked
15016 Print_Stopped The Stop button on the runtime Print progress dialog was clicked
15017 Print_Not_Available The specified printer does not match the available printers
15021 Print_NoDefaults_Printer Your workstation has no default printer set up
15022 Print_PrintReport_Ignored Printing started, so change of print report ignored
15023 Print_Printer_Ignored You attempted to change the printer in use after printing has begun or before any printing has occurred (the printer must be closed before commencing new output on a different printer)
15024 Print_Invalid_Position Attempt to set a print position that is outside the valid range
15025 Print_Unformatted_failed Printing of unformatted text failed; that is, the printUnformatted method request failed
15026 Print_PaperSource_Ignored Printing started, so change to the paperSource property ignored
15027 Print_PaperSource_Invalid Value of the paperSource property is invalid
15028 Print_Duplex_Invalid Value of the duplex property is invalid
15029 Print_Duplex_Ignored Printing started, so change to the duplex property ignored
15030 Print_Collate_Ignored Printing started, so change to the collate property ignored
15031 Print_In_Preview Value of the printPreview property is true so printer object cannot be reused
15032 Print_DocumentType_Invalid You changed printer.documentType to Print_Custom_Paper instead of calling the printer.setCustomPaperSize method
15033 Print_Metafile_Playback_Error Internal error occurred when attempting to play back a print metafile

If a value of 15015 or 15016 is returned (that is, printing was canceled or stopped), the printer has been closed and code is required in your method to logically end the print processing.

The following example shows the use of the print method.

buttonPrint_click(btn: Button input) updating;
vars
    result : Integer;
    report : ReportForm;
begin
    // Creates ReportForm transient class instance and references it by the
    // report local variable, which can be used to access the form controls.
    create report;
    // Specifies output is not directed to the preview file before printing.
    app.printer.printPreview := false;
    // Specifies the format of the pages to be printed.  As these are
    // default values, it is unnecessary to redefine them unless you
    // require a different format.
    app.printer.orientation  := Print_Portrait;
    app.printer.documentType := Print_A4;
    // Uses the print method to output frame2 of the form to the print
    // file twice.  The return value is stored in the result local
    // variable, and is checked to ensure that the print task has not
    // been stopped or cancelled.  The method returns if this is the case.
    // The close method then sends all buffered output to the printer
    // that prints the document.
    result := app.printer.print(report.frame2);
    if result = Print_Stopped or result = Print_Cancelled then
        return;
    endif;
    result := app.printer.print(report.frame2);
    if result = Print_Stopped or result = Print_Cancelled then
        return;
    endif;
epilog
    app.printer.close;
    delete report;      // Deletes the transient form instance.
end;