In another thread, CharlesS pointed out that the Desktop Printer Utility included the option to hack it in ResEdit so that you could create a desktop printer that sent output to an application to be processed. I've posted a hacked copy of the utility here, together with a sample AppleScript application to show how it's used:
https://www.dropbox.com/s/rzsf50cr1tvbj ... r.sit?dl=1
To create a desktop printer that writes a PDF to the Mac OS desktop (NOT the host desktop, but the desktop in SheepShaver or Qemu) you will need to do the following.
First, download and install MacGhostView32 from Macintosh Garden or elsewhere:
http://macintoshgarden.org/apps/macghostview-32
Next, make sure that Jon's Commands are installed in the Scripting Additions folder. You can find them in many places, e.g.:
http://macgui.com/downloads/?file_id=17717
Next, create an AppleScript application using the following code, which of course can be improved because I'm a total beginner at this kind of thing. The most intelligent part is the "replaceText" routine which I found online.
Code: Select all
-- osax: Jon's Commands
property SS : ":"
property RS : "-"
on open theFile
tell application "Finder" to set deskFolder to the path to the desktop folder
set myDate to day of (current date) as string
set myMonth to month of (current date) as string
set myYear to year of (current date) as string
set myTime to time string of (current date) as string
set myTimeText to replaceText(myTime, SS, RS)
set dateNameBase to myDate & "-" & myMonth & "-" & myYear & "-" & myTimeText
set goAhead to false
repeat while goAhead is false
try
display dialog "Type a filename for this PDF:" default answer dateNameBase
set newShortName to text returned of result
on error
deleteFile theFile --Jon's Commands
error number -128
end try
if newShortName is "" then
deleteFile theFile --Jon's Commands
error number -128
end if
set oldFile to (deskFolder & newShortName) as string
try
oldFile as alias
display dialog "File exists. Overwrite?" buttons {"Yes", "No"} default button 2
if button returned of result is "Yes" then set goAhead to true
on error
set goAhead to true
end try
end repeat
if length of newShortName is greater than 27 then
set newShortName to (characters 1 thru 27 of newShortName) as string
end if
renameFile theFile to newShortName
set newPDF to (deskFolder & newShortName) as string
moveFile theFile to deskFolder --Jon's Commands
tell application "macps2pdf"
open theFile
delay 1
set psBusy to true
repeat while psBusy is true
set psBusy to fileIsBusy theFile --Jon's Commands
delay 1
end repeat
quit
end tell
deleteFile theFile --Jon's Commands
end open
to replaceText(someText, oldItem, newItem)
set {tempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, oldItem}
try
set {itemList, AppleScript's text item delimiters} to {text items of someText, newItem}
set {someText, AppleScript's text item delimiters} to {itemList as text, tempTID}
on error errorMessage number errorNumber -- oops
set AppleScript's text item delimiters to tempTID
error errorMessage number errorNumber -- pass it on
end try
return someText
end replaceText
Name the script something like WritePDFtoDesktop and save it as an application in a convenient place.
Next, use the hacked Desktop Printer Utility to create a new Desktop Printer, using the option "Process PS File." Set it up to send the output to the AppleScript application that you created above, and give it any name you like.
EDIT: I forgot to mention: When you use this Desktop Printer for the first time, in the Print dialog, make these changes to the default settings: Background Printing, set to Foreground printing (not essential, but faster); Font Settings, check the box "Always download needed fonts"; Save as File, change PostScript level to Level 2 and 3, change Data Format to Binary, and for Font Inclusion, select "All But Standard 13", and click Save Settings.
When you print to this Desktop Printer, after a pause, you'll be prompted for an output filename. You'll be offered a default name based on the current date and time, but you can overwrite it with a better name. Names that are too long will be silently truncated. If the output PDF already exists on your desktop, you'll be prompted to enter another name. If you leave the filename blank, no PDF will be created.
The resulting PDF will be written to your desktop. You'll see the PostScript output file briefly appear on your desktop, but it will be deleted after the PDF gets created.
This is complicated to set up but easy to use in practice. I hope someone finds it useful.
EDIT: The maximum length of the filename is now 27 characters in both lines of code that count characters (I hadn't changed a 31 to 27 when I first posted). EDIT: The colons in the time string needs to be changed to hyphens to avoid truncated filenames.