Windows: Printing to File

Page Edition: 2002-07-05

  1. I have a document that I often need to print, but rarely need to change. I'd like to avoid needing to fire up my entire WP or DTP application just to print it. Is there any way in Windows [3.1/95/98/ME/NT/2K/XP] that I can print to file, and then easily print that file later?
    ...or...
    I need to print to a PostScript (.ps) file so that I can send it to someone who converts it to Acrobat (.pdf). Can I do this?
  2. Yes. You can print-to-file easily. However...
    subsequently printing from that file to the printer is also simple, but not drag´n´drop unless you write a script or an applet. And, as always on Windows, there are traps for the unwary.
  1. How do I print to a file?
  2. Some applications (e.g. Adobe FrameMaker) provide a [*] Print Only To File [d:\mydocs\resume.ps____]
    in their own
    [Print] or [PrintSetup] menus.

    If your app does this, use it, as it is likely to be more intuitive and smarter about last-used-directory and default filename suffix. plus you can skip the system configuration stuff here.

    If your application doesn't support this (and most do not), you need to make one system configuration change, then rely on that each time you need to print-to-file.
  1. How do I configure my system for print-to-file?
  2. You need to create a new "printer" of type "FILE".

    These instructions are for Windows 95. The process is similar for 3.1, 98/SE, ME, NT, 2000 & XP.

    1. If you already have a "real" printer of the target type installed, you'll need to re-name it so that later steps don't replace it (or give the new psuedo-printer an unexpected name).

      To rename a printer in Windows 95:
         
      [Start]:Settings:Printers
      Select printer icon/name, such as
         "Osborne BlaserJet 17i"
         
      File:Rename
         "Osborne BlaserJet 17i on LPT2"

    2. Add another printer of the same kind:
         
      [Start]:Settings:Printers:
      Double-click
      [Add Printer]
         
      (*) Local Printer
         
      Manufacturers [Osborne]
         Printers [BlaserJet 17i]
         (*) Keep existing driver
         Available Ports [FILE:]
         Printer name [Osborne BlaserJet 17i on FILE]
         Default (*) No
         Test Page (*) No

      Normally, you do not have to have this printer even connected to your PC. However, if you don't already have the driver on your system, and must install it from scratch, beware that some installs insist on finding and testing the I/O path to the printer. You may have to borrow the actual printer and hook it up temporarily. When done, just change the connection from LPT to type FILE:
  1. How do I print to file using this configuration?
  2. Skip the steps that don't apply:

    1. If your application doesn't have a [PrintSetup] menu (and sometimes it's buried in the [Print] menu), then you'll need to make the pseudo-printer your system default, at least temporarily. In Win95, this is:
         
      [Start]:Settings:Printers
         Select printer icon/name, such as
         "Osborne BlaserJet 17i"
         
      File:SetAsDefault
      Adjust any print options (color, resolution, gamma, page size, font download, etc.) as appropriate.

    2. Run the application from which you wish to print. If the pseudo-printer is not the system default, select the pseudo-printer from the application's [PrintSetup] or [Print] menu. Adjust any print options (color, resolution, gamma, page size, font download, etc.) as appropriate.

    3. Open the desired document or print object file (if you haven't already - and some apps won't let you configure the printer without a document open).

    4. Select any application-specific printing options, such as page range to print, crop marks, n-up, scaling, page size, etc.


      Screen capture of Windows *.prn dialog box
    5. File:Print [Print]
      Windows will pop a dialog box. There is no default print-file name, the default suffix is always
      .prn, and the default directory is almost never anything useful, so:
      • Change the directory to something sensible
        (such where the document file is)
      • Type in a meaningful file name
        (usually the same as the document file name)
      • Type in a meaningful file suffix. Examples:
        .escp   Escape-P printers
        .hpgl   HP-GL plotters
        .pcl     HP-PCL printers
        .ppa     HP-PPA printers
        .ps       Adobe PostScript printers
        .rtl     HP-RTL printers
      Note: Do not assume that your .xyz print-file can be successfully rendered on any printer that claims to support the XYZ page description language. PDL implementations tend to be highly printer-specific, with the exception of PostScript Level, and even with PostScript, don't generate level 3 for a level 2 or 1 printer, nor generate level 2 for a level 1 printer.

      If you routinely need to share precisely formatted documents with other people who don't own the exact model and configuration of your printer, invest in Adobe Acrobat PDF generating tools.

    6. Everytime you perform a new "Print to file" operation, this dialog box will pop up and request the filename, usually with useless defaults. Depending on your operating system, it may not warn or ask for confirmation if the file already exists. That's very efficient, one might say "Unix like", but you can do dumb things like overwrite your original document by using the same name and typing .doc instead of .ps.

  1. How do I print the print-file?
  2. You print such files by copying them in binary mode to the actual printer I/O port. Start a DOS window (or exit-to/boot-to a DOS prompt) and use the following command (where "filename.pdl" is the printfile, and "n" is the LPTn port to which the target printer is connected).

    C:> COPY /B  filename.pdl  LPTn:

    If you omit the "
    /B", you will print literal reams of wasted paper full of page description commands printed as commands text (or random characters if binary), instead of the page content those commands are supposed to describe.

    In Windows 3.1, you'll want to enable the "background execution" capability of the DOS window, otherwise your whole PC will be tied up until the printing completes.

    If the printer is networked (or USB), you may have to do some work to discover what "port" name to use instead of "LPTn". You may also discover that you need to have checked the box [*] for "allow DOS printing" when you installed that printer.
  1. Why does Microsoft make it easy to print to a file,
    but so awkward to print that file to a printer?
  2. There's a hazard.
    It's actually not that difficult to write a tiny drag´n´drop applet to do this. The applet only needs to open the target printer in "transparent" mode. But there's a reason why this isn't a standard feature on Windows, and you need to know about it, or you are likely to create printfiles that don't print properly.

    You need to reset the driver before every print-to-file operation.

    The reason for this is that some drivers attempt to keep track of the printer state, and not redo things that have already been done (as far as the driver knows) like downloading fonts, setting modes, etc.

    For example, if you make a test print to paper, then print to file using the same driver, the second (filename.pdl) job may have critical commands/data missing from the page description language data. The driver thinks the printer has already been setup. The same thing can happen (on output-only printers) if you hard-reset or cycle power between paper-only print jobs.

    When you go to print the file later, or give a copy to someone else to print on their BlaserJet 17i, the typefaces and font metrics may be so far off as to make the document unreadable.

    The only way I've found to reliably "reset" the driver is, within the app:
    1. Save and close the document (see below)
    2. Use [PrinterSetup] to select a new and totally different "printer", preferrably one that uses a completely different page description language.
    3. Re-select the desired printer.
    4. Re-open the document and print to file.

    Note: The WindowsGDI-VideoDriver-PrinterDriver architecture seems to be particularly fragile when changing printer drivers on the fly within an app. I was able to reliably crash NT 4 SP 3 just by cancelling a print-to-file in FrameMaker. At least save the document before making a printer change.

Go to hosting page [http://www.access-one.com/rjn/computer/computer.html]
Go to author's home page [http://www.access-one.com/rjn/]
Copyright © 1998, 2002
Robert J. Niland
PO Box 248
Enterprise
KS, 67441-0248 USA