How to Send PostScript Commands to Apple LaserWriter Printer (33047)



The information in this article applies to:

  • Microsoft QuickBASIC 1.0
  • Microsoft BASIC Compiler
  • Microsoft BASIC Interpreter for Apple Macintosh 3.0

This article was previously published under Q33047

SUMMARY

A PostScript Escape font and the DrawText library routine enable you to send PostScript commands to the Apple LaserWriter printer with the WINDOW OUTPUT # statement.

This information applies to Microsoft QuickBASIC Version 1.00, the Microsoft BASIC Compiler Version 1.00, and the Microsoft BASIC Interpreter Version 3.00 for the Apple Macintosh.

MORE INFORMATION

When BASIC sends output to the LPT1: or LPT1:PROMPT device, the currently chosen printer driver processes the output. Unlike the ImageWriter driver, the LaserWriter driver converts Macintosh QuickDraw ROM calls to PostScript commands before printing. PostScript is the command language (written by Adobe, Inc.) that is used to control the output of the Apple LaserWriter printer.

For more information about the PostScript language, there are several excellent books written by Adobe, Inc., published by Addison-Wesley Publishing Company, Inc.

To use literal PostScript commands, you must have a font named "PostScript Escape" available. The "Font/DA Mover" program can be used to copy fonts from one file to another. The PostScript Escape font can be obtained from user groups or Apple, Inc. For more information about the PostScript Escape font, please refer to "MacTutor Magazine," June 1986.

An alternate approach is to specify one of the current fonts as the PostScript Escape font. To do this, you must use ResEdit and change the "STR ID -8188" of the LaserWriter driver from "PostScript Escape" to the name of the font of your choice. Whenever this font is used for output, the LaserWriter driver passes this text directly to the printer as PostScript commands. Note that text in this font from other programs such as Microsoft Word or Apple MacWrite is also printed as literal PostScript commands.

A separate article describes how to set up the PostScript Escape font in a compiled application (query on the keywords POSTSCRIPT AND ESCAPE).

However, rather than defining a PostScript font, it is easier to embed PostScript commands as a picture comment when sending a picture to the LaserWriter, as shown in another separate article found by querying on the keyword PICCOMMENT.

Code Example

'    This program draws a box around the page using PostScript commands.
'    For the BASIC interpreter 3.00 and BASIC compiler 1.00, you must
'    add the following statement to access the DrawText routine:
'  LIBRARY "TOOLLIB"
'    This LIBRARY statement is not needed for QuickBASIC programs.
'    The variable PS% must be initialized to the font number of the
'    PostScript Escape font:
   PS%=xxx  ' xxx must specify font number of PostScript Escape.
   OPEN "LPT1:" FOR OUTPUT AS #1
   WINDOW OUTPUT #1         ' Redirects window output to printer.
   PRINT "PostScript will draw a box around this page."
   TEXTFONT PS%             ' Set the PostScript Escape Font
   DrawText "initclip  clippath  stroke"    ' PostScript commands
   CLOSE#1
				
Note: You cannot use PRINT; you MUST use DrawText or DrawString to send the PostScript commands. PRINT always sends information one character at a time, but PostScript commands must be sent in whole strings. If you attempt to use PRINT, a PostScript error results, and no output appears.

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:KB33047