Thursday, May 28, 2020

#1 2020-03-28 12:55:22 am

syamala
Member
Registered: 2020-03-27
Posts: 1

Is there a way to print a file from default printer using Apple script

We have a file path , how can we print it from a printer

Using lp file_path, I was able to print only PDF's. Unable to print docx,xlsx,ppt,.numbers,.pages,.key

And I tried individual scripts as below

set filePath to "/Users/syamala/Desktop/Print/Book1.xlsx"
tell application "Microsoft Excel"
    activate
    open filePath
    print out active sheet
    close active workbook saving no
end tell

it is not working

I am using virtual printer : PDF Writer and PDF Printer.

Any help is much appreciated


Filed under: print, lp, Apple Script

Offline

 

#2 2020-03-28 06:03:45 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: Is there a way to print a file from default printer using Apple script

syamala wrote:

We have a file path , how can we print it from a printer

it is not working

I am using virtual printer : PDF Writer and PDF Printer.


A virtual printer is an application that replicates the software interface for a physical printer and allows the user to carry out various tasks without actually printing anything. It is like printing some text on your screen (into the some window. For example, the text you see as output in the Terminal window)... and not on the paper.

How want you print using something that doesn't print?...

If you want print on your default printer, which is physical device, then try something like this:

Applescript:

set defaultPrinterName to "HP_LaserJet_52001"
set aFile to POSIX file "/Users/syamala/Desktop/Print/Book1.xlsx"

tell application "System Preferences" to print aFile with properties {target printer:defaultPrinterName} without print dialog

NOTE: I don't have currently any printer to test this my propose.

Last edited by KniazidisR (2020-03-28 06:28:53 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)