@PDF Choose PDF Menu Item in Print Dialog (All Browsers)

Macro built in response to this request:
Select Item in Drop Down Menu in Print Dialog Box

Changes in Ver 2.0

  • Greatly simplified macro, taking advantage of the technique showed here by @peternlewis. This removes the need for a custom script.
  • Added Prompt to provide for user selection of available PDF Menu Items
  • Added support for all browsers (that use the standard Print menu)

Example Output


MACRO:   @PDF Choose PDF Menu Item in Print Dialog (All Browsers) [Example]

~~~ VER: 2.0    2017-01-02 ~~~


@PDF Choose PDF Menu Item in Print Dialog (All Browsers) [Example].kmmacros (13 KB)
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


Author.@JMichaelTX (based on a script by @ccstone)


  • ** Choose/Click PDF Menu Item on Print Dialog**


  1. Move this macro to a Group that is active for Browsers
  2. Assign a Trigger of your choice.
  3. CHANGE the magenta colored Action
    "SET List of PDF Menu Items for Prompt"
    to match the list of available items on your Mac.


  1. Activate Browser (Safari or Google Chrome)
  2. Trigger this macro


This macro built in response to:
Select Item in Drop Down Menu in Print Dialog Box

TAGS: @PDF @UI @Browsers @Chrome @Safari @AppleScript

• Any Action in magenta color is designed to be changed by end-user
• This macro uses Google Search and Google Chrome, but can be easily changed

• To facilitate the reading, customizing, and maintenance of this macro,
key Actions are colored as follows:
• GREEN -- Key Comments designed to highlight main sections of macro
• MAGENTA -- Actions designed to be customized by user
• YELLOW -- Primary Actions (usually the main purpose of the macro)
• ORANGE -- Actions that permanently destroy Varibles or Clipboards

(1) Keyboard Maestro Ver 7.3+
(2) Yosemite (10.10.5)+


Just updated the Macro to Ver 2.0.

Please excuse my English @JMichaelTX is not good. I’ve created with Shortcus this palette with print commands. Without Applescript etc.

The palette can be accessed in any program with a touch gesture (BetterTouch Tool) on the trackpad. I have made a small video here.
A tutorial will follow the next days.

Greetings from Germany :slight_smile:

Sounds good.
Please post your tool/macro/etc in a new topic.

To make this macro work on your Mac, you will need to make the change indicated in #3 of the Macro Setup section.


Change the Menu Items in this KM Variable:

To the Menu Items shown in your PDF Button Menu:

Hi. I know this is an old thread, but I can't seem to find this apple script mentioned.
Am I missing something?

I don't know what AppleScript you are referring to. My macro does NOT use AppleScript.

It's weird, a few days ago the top of this post that shows the original macro wasn't there, so I've got to be mistaken - appologies! I also see that there was a reference to a macro (which i could not find until now) and not a script. Thanks for clearing.

@JMichaelTX Great work, thank you very much. Very Very useful and handy macro.
I have got a suggestion to even improve your great work.

I'm not familiar (yet) in sharing macro's and actions's here. So I'm gonna share the 'code' of one simple action in this text box and a image. Hope it is helpful.


Here we go :

    # Additional aid from tsboh

    # 1) enable this action
    # 2) just run on only this action: 'Try action'

    ls "/Library/PDF Services" 
    ls "$HOME/Library/PDF Services" | sort --ignore-case

    # 3) then (for now) copy list from the display result window and 
    #      paste into the next action: 'SET List of PDF Menu Items for Prompt' 
    #      (first three entries are standard leave them in their) replace the rest
    # 4) disable this action

    # future enhancement: ==> set variable and append to the first standard 3

Hey @tsboh

Sort fails on my system apparently due to some Unicode characters.

Here's a workaround:

export LC_ALL='C';
'ls' "$HOME/Library/PDF Services" "/Library/PDF Services" | sed -E -e '/^\//d' -e '/^$/d' | sort --ignore-case;


Passing by and sticking my nose in. ls doesn't typically provide reliable/consistent output that lends itself to manipulating file paths, as stated in its man page. In its use above by @tsboh who put forward an otherwise very nifty method of retrieving PDF menu items, ls does produce additional lines for informational purposes that are superfluous to the requirements here.

This command would perhaps be more well-suited:

basename -s .pdfworkflow /Library/PDF\ Services/* ~/Library/PDF\ Services/* | sort -dfi

NB: sort -dfi is equivalent to sort --dictionary-order --ignore-case --ignore-nonprinting

± @ccstone's sed command for those that encounter the issue he mentioned causing sort to fail.

On my system (which has a limited selection of PDF options that I never use), the above command outputs this:

Add to iBooks
Save PDF to Scrivener
Save to iCloud Drive
Save to Web Receipts
Send in Mail
Send via Messages

which is cleaner than the ls output, which was:

/Library/PDF Services:
/Users/CK/Library/PDF Services:
Add to iBooks
Save PDF to Scrivener
Save to iCloud Drive.pdfworkflow
Save to Web Receipts.pdfworkflow
Send in Mail
Send via Messages

Hey @CJK,

Spiffy!  :sunglasses:

Yours still has anti-sort-ial issues on my system, but that's easily fixed with the LC_ALL setting.

export LC_ALL='C';
basename -s .pdfworkflow '/Library/PDF Services/'*  ~/'Library/PDF Services/'* | sort -dfi

I've also changed the leaning-toothpicks (escapes) to the quoted strings I prefer.


1 Like

:+1: and thanks for the improvements

This macro (and variants) fails with Ventura. My diagnosis is that the PDF button in the print dialog has changed. Pressing the "PDF" button immediately takes you to the Save as PDF file picker. To get the menu list requires pressing the down arrow in the right hand part of the PDP lozenge. I don't know how to do that in KM.

Does the down arrow have a name? Or is there another way of getting the drop down list?

Somebody at MPU or Automators (I forget which) pointed out that the 3 dots at the end of Save as PDF… have become an ellipse in Ventura (or vice versa). Something along those lines should sort it for you.

Thanks for your comment, but it doesn't have deep enough detail for me. The critical point is when the macro gets to:

Under Monterey (and earlier), this button opens the drop down listing PDF options.

Under Ventura is goes straight to the Save as PDF file picker.

I don't know how to press the down arrow next to the PDF button.

Does it have a name?

It looks as though what was a single "menu button" named "PDF" has become two items in Ventura -- a "button" and a "menu button", both named "PDF". And the KM action chooses the button, not the menu button.

A quick fix might be to use a "Detect Image" action then click just inside the right edge of the detected image. Or maybe use AppleScript GUI scripting -- you'd have to target the correct process but it would be something like:

tell application "System Events"
	tell item 1 of (every process whose frontmost is true)
		click menu button 1 of group 2 of splitter group 1 of sheet 1 of window 1
	end tell
end tell

...which should work for the frontmost window of the frontmost app, once the "Print" sheet has been opened.


Magic! That works exactly. Now I have to understand why.

Edit: I have discovered the UI Browser and can see why the 'click' works and how it is constructed.

Keep in mind that this is a pop-up menu (button) and not a normal button.

1 Like