Having trouble with this apple script below to print multiple pdf file with specific properties.
tell application "Finder"
set selectedFiles to selection as alias list
end tell
tell application "Fuji_Xerox_Colour"
print selectedFiles with properties {paper size:"A4"}
end tell
I get a syntax error when trying to compile on the first {.
Expected “given”, “with”, “without”, other parameter name, etc. but found “{”.
If I remove the
with properties {paper size:"A4"}
It works but i need to make a few different scripts with different properties.
Your right the print command is pretty much useless without being able to set the paper size.
Cant see anything more under the “Fuji_Xerox_Colour” dictionary.
I think I will have get the Apple Script to pass the files onto a shell command lp which looks like it can dictate the media size -o media=A4
This is what I have but getting an error.
error “lp: No such file or directory” number 1
tell application "Finder"
set selectedFiles to selection as alias list
end tell
set filePaths to {}
repeat with thisFile in selectedFiles
set end of filePaths to quoted form of POSIX path of thisFile
end repeat
set printCommand to "lp -d Fuji_Xerox_Colour -o media=A4 " & filePaths as text
do shell script printCommand
Looks like my previous attempt was working but only for a single file not multiple selections.
tell application "Finder"
set selectedFiles to selection as alias list
end tell
repeat with thisFile in selectedFiles
set filePath to quoted form of POSIX path of thisFile
set printCommand to "lp -d Fuji_Xerox_Colour -o media=A4 " & filePath
do shell script printCommand
end repeat
The above apple script / shell script combo works with multiple files and will print everything to A4.
The lp shell command has alot more options that can be set. Far more than the Apple Script Print command.
Here is a variation that should print multiple files while foregoing the applescript repeat loop. It requires that there be a space between file names (i.e. set delimiters to space). Basically, it runs the loop within the shell so there will only be a single instance of the shell.
set printCommand to "for f in " & filePaths & "; do lp -d Fuji_Xerox_Colour -o media=A4 \"$f\"; done"
I think that in this scenario, the noun is print settings and the verb is print.
As @zevrix suggests, copies is a property of print settings but paper size is not.
Each application can provide its own settings. Applescript’s inherent print settings are lacking. I get the impression that they once put together a meagre package (although it does include fax number) that every app uses without changes. However, even an app with broken applescript support like Word can have a bucket of them including paper size (a property of page setup which is typically the property of a document).
the print command in Word is totally broken ever since Monterey. if you include with properties it will just return an error (and sometimes crash Word).
print out seems to work - even though it bears a note: “This command has been deprecated; use the Print command in the Standard Suite” (referring to the print command that’s now broken).
Part of the reason is that the paper sizes come from the printer description software and the names and sizes are not standardized.
Even “letter” and “legal” have different names and sizes in various printers.
It’s not completely useless, as it will not change the page size when you print. In most cases that means the printer will use the last size used. In some cases the printer will always revert to a default size.
A few years ago, when I wrote scripts that were printing to any one of a number of printers with various sizes the only way to automate that was to use UI scripting to change the Page Setup options.