• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Print to PDF
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Print to PDF


  • Subject: Re: Print to PDF
  • From: deivy petrescu <email@hidden>
  • Date: Tue, 18 Mar 2008 21:25:48 -0400


On Mar 18, 2008, at 20:37, Steve McMillen wrote:

Hmm... that sounds a whole lot easier :)

Since you have to open the print dialog first, I assigned it to "Cmd- P". This way I can press Cmd-P twice. Seems to work ok in different apps.

on 3/18/08 2:44 PM Enrique Terrazas said the following:
On Mar 18, 2008, at 1:55 PM, Steve McMillen wrote:
There was a thread on this list about automating the "Save as PDF" option available in the print dialog of all applications. I original poster suggested maybe using GUI Scripting which is how I did it. But there were some difficult challenges such as selecting the sub-item of the menu button and working with sheets as well as dialogs.


The latest issue of Macworld shows how to assign a keyboard shortcut to items in the PDF popup if you are running Leopard. Basically, you add one for all applications in the keyboard preference, and make sure to list the item name as it appears in the popup.

Enrique Terrazas

Steve

I don't know... I like the script idea.
Something must have changed in Leopard, I know this would not work before.
But it does now.
I could not have the "Save" dialog click on the desktop.
But I found a workaround and it does most of the work.
I used the sheet instead of the window.


I tested with preview, but you could use "current app"

Thanks! I would not have tried it if you had not asked...

______

# Saves current document open in foreground app as PDF using the Print dialog "Save as PDF" option


### Set process name based on the current app ###
# This allows the script to run with whatever app is in foreground
# Note: Some apps use a property sheet and some use a window for the print
# Dialog so depending on which we need to take different actions


set process_name to name of current application

# If needed, you can hard-code the app name by uncommenting the following:
# as is done below


#
set process_name to "Preview"
#

tell application "System Events"
set frontmost of process process_name to true
tell process process_name

# Open the print dialog
keystroke "p" using command down
set k to 1
# Wait until the Print dialog opens before proceeding
repeat until exists sheet 1 of window 1
if k > 30 then exit repeat
set k to k + 1
end repeat
set prdlgref to a reference to menu button 1 of sheet 1 of window 1
tell prdlgref
click
tell menu 1 to tell menu item 2 to click
end tell
set k to 1
# Wait until the Save dialog opens before proceeding
repeat until exists window "Save"
if k > 30 then exit repeat
set k to k + 1
end repeat
delay 0.5
keystroke "H" using command down
tell radio button 3 of radio group 1 of group 2 of window "Save" to click
end tell
end tell




_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
References: 
 >Re: Print to PDF (From: Steve McMillen <email@hidden>)
 >Re: Print to PDF (From: "Enrique Terrazas" <email@hidden>)
 >Re: Print to PDF (From: Steve McMillen <email@hidden>)

  • Prev by Date: Re: extract URL from general text
  • Next by Date: Re: Which version of InDesign created a document?
  • Previous by thread: Re: Print to PDF
  • Next by thread: How to open application (Preview) at a specific size and location on the screen
  • Index(es):
    • Date
    • Thread