Ah a bit of a difference, no?
I think I found the error, in the line
set theFile to ((path todesktop) astext) & "print test.pdf"
from my previous post the formatting got messed up. there should be spaces between to and desktop and as and text
so the line should be
set theFile to ((path to desktop) as text) & "print test.pdf"
Also you don;t need to do the
set sel to theFile
command you could just use theFile in the open command i.e.:
open theFile using -- rest of the line as is --
Finally any reason you are trying to print out the file this way and not use the print command or print through Preview? just curious.
I have a default printer named Sammy in my System Preferences > Printers & Scanners configuration. The following will print a PDF on my Desktop to this default printer. I had to replace the clause without print dialog with its class representation to side-step AppleScript detecting a second command (print) name. Also, this approach does not permit the use of print properties such as copies, starting page, ending page, etc. Replace Sammy with your default printer name, not its path or .app extension.
set theFile to POSIX path of ((path to desktop) as text) & "re_format.pdf"
tell application "Sammy"
print theFile without «class pdlg»