@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

image


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

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

DOWNLOAD:

@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.


ReleaseNotes

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

PURPOSE:

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

MACRO SETUP

  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.

HOW TO USE:

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

REFERENCE:

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

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

USER SETTINGS:
• 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

ACTION COLOR CODES
• 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

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


image

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.

Example

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.

Thanks.

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;

-Chris

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.

-Chris

1 Like

:+1: and thanks for the improvements