Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Printing to any printer from Classic Classic
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.
    •    
  • Currently 3.50 / 5
  You rated: 4 / 5 (4 votes cast)
 
[10,338 views]  

Printing to any printer from Classic | 8 comments | Create New Account
Click here to return to the 'Printing to any printer from Classic' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
PostScript doesn't work?
Authored by: jecwobble on Oct 12, '04 12:58:06PM

I submitted a very similar hint a few months ago for printing from the RealPC in Classic. In my scenario, I save a *.prn file from Windows 98 generated from a PostScript driver. I seem to recall looking at the PRN file and noticing that it is in fact a PostScript file. It printed just fine with Printer Setup Utility without any PDF conversion.

Have you tried a PostScript file? In fact, I think you can drop a number of different file types onto PSU and it will attempt to print them by default. I haven't tested that extensively, though.

[ Reply to This | # ]

Printing to any printer from Classic
Authored by: mm2270 on Oct 12, '04 01:02:37PM

Thank you! Thank you! THANK YOU!

This simple script solves a problem I've been working on at my job. We have a workflow with our separator where they send us .ps files of images they scan and we needed them to print to an HP color printer set up on our network here unattended and automtically. We've been attempting to write a script to hand off the PS file to the printer with no luck. After looking at your script I realized we were approaching it from a much more difficult place than necessary. I never realized that a simple "open with Print Setup Utility" would do it.

FYI- actually didn't need to convert to PDF first, a simple folder action opening the files with Print Setup Utility set to a default printer seems to do the trick! Fabulous!

Now I just need to figure out how to make it print 3 copies of each image.

Thanks again!



[ Reply to This | # ]
Printing to any printer from Classic
Authored by: strunx on Oct 13, '04 08:29:01AM

Anybody aware of a way to do this with .plt HPGL plotfiles?
Currently I drive my HP DesignJet 2500CP with Ethernet only interface by sending raw files via Folder Actions Script using lpr -l <filename> in Terminal. Not too elegant.
Printer Setup Utility should be capable of handling plt files, since they pop up there, once sent from terminal.
I tried to alter both scripts mentioned unsuccessfully...



[ Reply to This | # ]
Printing to any printer from Classic
Authored by: strunx on Oct 13, '04 08:57:48AM

OK, this seems to work:

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
tell application "System Events" to set FilePath to POSIX path of TheFile
do shell script "lpr -l " & FilePath
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

I use a MIO internal 10/100 printserver and have the plotter setup in Print Center as default using either HP or GimpPrint provided ppd's.

I guess this could be helpful for folks with missing DesignJet drivers as well. Just set up the Printer using IPP and its IP adress.



[ Reply to This | # ]
Printing to any printer from Classic
Authored by: father2a-f on Oct 18, '04 01:55:57PM
Now I just need to figure out how to make it print 3 copies of each image.
Try setting Copies: to 3 in the Classic app's print dialog and then click the Save Settings button at the lower left corner. It will keep that copies settings until you change it and re-save. I tested it right now and it printed 3 copies of an item through a legacy app and the default OS X printer using the following folder action script:

on adding folder items to this_folder after receiving added_items
        repeat with each_item in added_items
                tell application "Printer Setup Utility" to open each_item
                delay 5
                tell application "Finder" to delete each_item
        end repeat
end adding folder items to
I had the Finder delete the file so that it would clean up after itself. Also, thank you and Dave Howell for this hint. I've been looking for just a solution.

[ Reply to This | # ]
Printing to any printer from Classic
Authored by: snarke on Oct 28, '04 05:25:01PM
You're welcome. :) I posted it when I happened to trip across this hint and thought "I'm doing it a different way that's not so Unix-y. I guess there are some other people who might want to hear about it."

Note that you can also print from an OS9-only computer this way. You have to AppleShare the print folder on an OSX-machine. So you save the .ps/.pdf file across the network to the Folder Action'ed folder on the OSX computer, and off you go.

Finally, the reason I have the .ps to .pdf code is that when I first wrote the script, I was running Jaguar, sharing my DeskJet, and unaware of the GIMP printing drivers, and a .ps file wouldn't print. I couldn't test to see if it was still necessary because not only am I running Panther now, but I also have GhostScript installed and a lot of other non-standard stuff (for the TeX typesetting system, in this case), and what worked for me might not work for other people. I found a reference somewhere that Jaguar had "pstopdf," and I figured better safe than sorry.

[ Reply to This | # ]

Printing to any printer from Classic
Authored by: emendelson on Oct 13, '04 07:18:19PM

Very elegant script, and much better than the one I had cobbled together. One small point: Under Panther, you don't need any of the code that converts .ps files into .pdf. Panther does it automatically when printing. So you can remove the if/else/endif sequence except for the one line that tells the Printer Setup Utility to open the file.



[ Reply to This | # ]
Printing to any printer from Classic (question)
Authored by: jj1000 on Oct 25, '04 02:54:02PM

I used the hint for printin from Finale in Classic to a HP PSC 2410. It worked but I can only get it to print at extremely high quality (i.e. extremely slow) which is impractical for printing out drafts. I tried changing the setting is another application but it didn't help. Any suggestions?

Thanks,
Josh



[ Reply to This | # ]