Printing a file on my computer

Is there a way to print a file sitting on my computer with a procedure? I could open the file and then the user could print it, but I would prefer to Panorama just print it without any user intervention. The file could be in several different formats, PDFs, PNGs, DOC, or XLSX.

You might be able to do it with AppleScript.

Here is a sample AppleScript I found that might be a starting point for you. I’m no AppleScript expert so I can’t give any guidance beyond this.

on run {input, parameters}
	set theDocument to input
	tell application "TexEdit"
		launch
		set the Doc to theDocument
	print theDoc with properties {target printer:"default"} without print dialog
	end tell
	tell application "TextEdit"
	return input
end run

You can also use an AppleScript to get the default application associated with any file:

let theApp=""
applescript {tell application "System Events"
	get default application of file "/Users/garyyonaites/Documents/Isabelle.jpg"
end tell},theApp
theApp=arraylast(array(theApp,1,{:"}),":")
message theApp

The above code returns Preview.app for this file. You could incorporate this in with the earlier code to automatically get the proper application to open for that file.

1 Like

I have a form that I print from my Panorama 6 version to endorse checks, which does it automatically within Panorama, but because it is a special page size and feed, doing that within Panorama X is awkward, so I just use the openanything command to open a similar file in Pages and print it from there.

Thanks Gary.

That’s cool Gary, I didn’t know that AppleScript could do that.