txt2PDF

I ran into an issue where from within my program, I needed to save the contents of a window to a PDF file and found it confusing and time consuming to say the least. But, I finally cracked the egg when I created the following code to use. You’ll need to experiment with the different types of files that it can convert.

set TheFile to (choose file with prompt "Choose a textual file type to convert...")
set the_posix_file to POSIX path of TheFile
set terminalCommand to ""
set convertCommand to "/System/Library/Printers/Libraries/./convert "
set newFileName to the_posix_file & ".pdf"
set terminalCommand to convertCommand & "-f " & "\"" & the_posix_file & "\"" & " -o " & "\"" & newFileName & "\"" & " -j \"application/pdf\""
do shell script terminalCommand

This solved a few issues for me and hopefully it will help somebody else out as well.
chuck

Nice. Certainly better than fiddling with GUI scripting.