printUnformatted

printUnformatted(text: String): Integer updating;

The printUnformatted method of the Printer class takes unformatted print text and passes it to the printer, bypassing the Windows Printers Control. This method enables you to output text to a dot matrix printer; for example, using your specified page depth.

Use the text parameter to specify the unformatted text that is to be printed.

You must embed all control commands that you require in your parameter string; for example, top-of-page, carriage return, line feed, and so on.

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

This method is compatible only with dot matrix, daisy wheel, or a printer that is capable of printing a single line or single line feed. It does not work with LaserJet printers, which must print a page at a time. An exception is raised if the method fails.

The following example shows the use of the printUnformatted method.

vars
    text    : String;
    loop    : Integer;
    printer : String;
begin
    // Set the printer to the IBM Proprinter
    printer := 'IBM Proprinter XL';
    app.printer.setPrinter(printer);
    // Set page depth to 3 inches - don't bother setting up the documentType
    text := #'1b 43 00 03';
    app.printer.printUnformatted(text);
    // Print 4 * 4 labels
    loop := 1;
    while loop < 50 do
        loop := loop + 1;
        text := CrLf & CrLf & CrLf;
        app.printer.printUnformatted(text);
        text := '         100831.7                      100831.8
                 100831.7                      100831.8     ' & CrLf & CrLf;
        app.printer.printUnformatted(text);
        text := 'Sockburn                       Sockburn
                 Sockburn                      Sockburn' & CrLf & CrLf;
        app.printer.printUnformatted(text);
        text := '123456                         123457
                 1234568                       1234569     ' & CrLf & CrLf;
        app.printer.printUnformatted(text);
        // Skip to top of page ( 3inch page );
        text := #"0C";
        app.printer.printUnformatted(text);
    endwhile;
    app.printer.close;
end;

The Printer category global constant values that can be returned by the printUnformatted method are listed in the following table.

Return Value Global Constant Description
0 Print_Successful The print was successful
15003 Print_Printer_Not_Open The printer is not open
15004 Print_TextOut_Error Text output to printer failed
15005 Print_Printer_Open_Failed Opening the printer failed (it may be off-line or incorrectly configured)
15013 Print_Currently_Open The printer is currently open
15014 Print_Failed_To_Obtain_Printer The task failed to obtain the printer
15017 Print_Not_Available The printer does not match the available printers
15025 Print_Unformatted_failed Printing of unformatted text failed

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