Automator "Set PDF metadata" window size? I have a workflow in automator that "receives a selected PDF file in Finder", then "Open finder items", follow by "Set PDF Metadata"

When running the workflow, "Set PDF Metadata" opens a window that takes some inputs (title, author, and so on), and then requires me to press "Continue" to move on the next step of the workflow.

The window that "Set PDF Metadata" opens is always partially minimized, so I have to manually resize it bigger every time I run the workflow. Is there some way I can specify the size and position that the window should open at?

To replicate this behavior a simple workflow that goes as follows should work:


Get specified finder item, and specify a PDF file
Open finder items (open with default application)
Set PDF metadata, with the "Title" and "Author" boxes checked


Further information and screenshots:
Default PDF application is Preview

OS is MacOS Sierra 10.13.3
Yes, it is possible to set the position and size of the Set PDF Metadata action's window when run from an Automator Service, however it requires a bit of a creative workaround.

I have tested the following and it works for me under macOS High Sierra.

There are two primary components for this process, one being the Automator Service named Edit PDF Metadata, and the other, an AppleScript application that sets the position and size of the Set PDF Metadata action's window.

For the Automator Service, which I saved as Edit PDF Metadata, the image below shows the settings.


Note that the PDF document does not first have to be opened to set the metadata and why there is no Open Finder Items action. If you were doing it the see information in the document as a reference to be used in the Set PDF Metadata action, you can add it back in.


Example code for the Run Shell Script action:

open -a "/Applications/Resize Set PDF Metadata Window.app"
echo "$1"



Note that the fully qualified pathname to the app does not necessarily need to be used and the open command could be shortened to open -a "Resize Set PDF Metadata Window". Then it doesn't matter where the Resize Set PDF Metadata Window.app is saved, it's found automatically. I've include the fully qualified pathname just so there was no ambiguity.




Next, the desired position and size of the window for the Set PDF Metadata action needs to be determined:

In Script Editor, open a new document with the following AppleScript code, but do not run it yet, just have it ready.

tell application "System Events" to ¬
    get {position, size} of window 1 ¬
        of process "com.apple.automator.runner"


Now in Finder, select a PDF document and right-click selecting Edit PDF Metadata from the Services section of the context menu.

Then position and resize the Set PDF Metadata action's window on the screen as wanted, leaving it on screen for the time being, then back in Script Editor, run the code you prepped to get the desired position and size of the window for the Set PDF Metadata action.

On my system it returned, e.g.: {{870, 280}, {700, 290}}, on my 27" Thunderbolt Display.

Make note of the results for use with the code, which is used next, to create the Resize Set PDF Metadata Window.app in Script Editor.

You can now click the Cancel button on the Set PDF Metadata action's window, as it has served its purpose to this point.

Now create the Resize Set PDF Metadata Window.app in Script Editor using the following example AppleScript code:

tell application "System Events"
    set i to 0
    repeat until (exists window 1 of process "com.apple.automator.runner")
        delay 0.1
        set i to i + 1
        if i &gt; 30 then return
    end repeat
    tell window 1 of process "com.apple.automator.runner"
        set position to {870, 280}
        set size to {700, 290}
    end tell
end tell



Change the value of set position to and set size to as appropriate and save as an application named Resize Set PDF Metadata Window in the /Applications folder.
Note that on my system 30, in if i &gt; 30 then return, equates to ~5 seconds and is used so repeat until is not an endless loop, if something happens and window 1 of process "com.apple.automator.runner" doesn't appear for some reason.


Before really using the new Automator Service for the first time, you need to add Resize Set PDF Metadata Window.app to: System Preferences > Security &amp; Privacy > Privacy > Accessibility

With that done, Edit PDF Metadata is ready to used on a PDF document in Finder from the Services section of the context menu. It is also available from the Finder > Services menu as well. Also a keyboard shortcut can be assigned to the service in: System Preferences > Keyboard > Shortcuts > Services > Files and Folders

Also note that by default, the metadata added to the selected PDF document is automatically saved upon pressing the Continue button, so there is no need to use the Quit Application action set to Preview with the [√] Ask to save changes check box clicked. That is unless you added the Open Finder Items action, then add back the Quit Application action set to Preview too. (Note that Ask to save changes did not work in my testing.)



NOTE: Use caution with the Rename PDF Documents action, because if the Title check box is checked in the Set PDF Metadata action's window but text box is left blank, it will delete the PDF document upon clicking the Continue button! (This appears to be a bug in this action under macOS High Sierra.) Additionally, if you set the Title to the name of an existing PDF document, while the metadata is changed, nonetheless the target file is not renamed. As always, insure you have proper backups before running automated services upon your files.



The only drawback to this method that I can think of, is that only one Automator Service can be run at a time, this one, otherwise it will not be able to get window 1 of process "com.apple.automator.runner" if there is more than one "com.apple.automator.runner" process running. But how often does one really need to have more then one Automator Service run at a time.



If you do not want to have the Dock Tile for the Resize Set PDF Metadata Window.app show on the Dock, then in Terminal use the following command:

defaults write '/Applications/Resize Set PDF Metadata Window.app/Contents/Info.plist' LSUIElement -bool yes


Afterwards, you can use the command with -bool no to have to have the app's Dock Tile show on the Dock.



Note: The example AppleScript code is just that and does not employ any error handling and is meant only to show one of many ways accomplish a task. The onus is always upon the User to add/use appropriate error handling as needed/wanted.