Printing to any printer from Classic

Oct 12, '04 09:44:00AM

Contributed by: snarke

I still use WordPerfect and Freehand 9** on a regular basis; both are non-Carbonized applications, and run under Classic. This is all well and good until it's time to print. For Freehand, since I'm usually printing weird paper sizes, I have to plug my USB DeskJet printer into my laptop and print directly. But if I'm printing standard letter size, I really wanted to be able to print to the old PCL laser printer connected to the house server. But printer sharing only works from OS X. What to do?

Simple. Set up a Folder Action. It works like this: in Classic, I choose the LaserWriter8 (or some other PostScript printer driver) in the Chooser. Then I "print" to a file, not the printer, and save the resulting file to a folder (that I've already bookmarked for convenience) that I call "Printing Box." I usually save it as PDF, but that might be an option I have just because I have full Adobe Acrobat installed. I modified my script so that you don't need Acrobat to make this hint work.

** Yes, I know there's Freehand MX. But even though Freehand 9's AppleScript support is grotesque and pathetic, I do use it. Freehand MX has the same tragically incomplete dictionary; however some of those AppleScript commands that at least work in 9 are broken in MX. I'm hoping, probably foolishly, that they'll at least get FH12 back to the minimum level of utility that 9 has (which, by the way, is the same dictionary as FH5).

Read the rest of the hint for the script...

The Printing Box folder has a Folder Action associated with it, which I named "Folder Action Print Server." It's this:

-- Folder Action Print Server, created 2004 by Dave Howell
-- Placed in the Public Domain.

on adding folder items to PrintFolder after receiving FilesToPrint
  -- FilesToPrint will contain a list of file references to the added items 
  repeat with TheFile in FilesToPrint
    set FileInfo to info for TheFile
    if name extension of FileInfo is "ps" then --must make it into a PDF
      -- get the Unix-style path of the file to convert:
      tell application "System Events" to set FilePath to POSIX path of TheFile  
       do shell script "pstopdf \"" & FilePath & "\""
    else if name extension of FileInfo is "pdf" then
      tell application "Printer Setup Utility" to open {alias (TheFile as string)}
    end if
    repeat while (busy status of (info for TheFile))
      delay 1
    end repeat
    tell application "Finder" to delete TheFile
  end repeat
end adding folder items to
If you save a PostScript file to this folder, then this script will use pstopdf to convert it to a PDF file. The arrival of a PDF file (whether through conversion, or because you just put one there) tells the "Printer Setup Utility" to open it. Lo and behold, if PSU opens a PDF, it will print it to the current default printer, which can be any printer set up under OS X. Any file, whether it's printable or not, will then be deleted by the "busy status" loop. I first created this script for Jaguar, although my older one didn't have the ps part of the code.

Comments (8)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20041007072143915