Print PDF to Dropzone07 Dec 2023
Recently I was exporting some web pages in PDF format. It was a simple enough task, and I was making use of the PDF option in the macOS standard print dialog window. The thing was I kept generating them, dragging them off into Dropzone (a shelf app with a plugin architecture for processing files) while I sorted and gathered, and then I dragged each off where it needed to go; a variety of folders and e-mails. Really what I would have liked to do was to simplify that middle step of saving the PDF somewhere and then dragging it into Dropzone for easy access. I had a bit of time to work on something today, and so I created a little workflow to just reduce that friction a little bit.
macOS Print Plugins
You may have noticed that the print dialog on macOS has a PDF button that includes a set of options to do various things upon generating a PDF version of a piece of printable content.
Some of these are standard entries, and some are custom entries added by applications, or sometimes manually. This was the obvious place to add my own option to add my generated PDF to Dropzone.
The “traditional” way to do this was via a Print Plug-in in Apple’s Automator app. However, Automator is on its way out, being replaced by Shortcuts. But, Shortcuts can’t explicitly create Print Plugins yet. I did a bit of research, and while it looks like you used to be able to create shell script-based entries for the PDF export menu, it seems like they no longer work (theories suggest a change in security), and my own simple experiments bore that out. The scripts worked stand alone, but not when I added them into the PDF menu.
The upshot was I was relegated to relying on Automator. It still works, but presumably at some point in the next year or two, I’ll be looking at a different trigger mechanism.
Now that was decided, I needed to figure out how I could get Automator to ‘talk’ to Dropzone.
While Dropzone has a plugin ecosystem that allows you to operated on things added to it, the automation options for interacting with the application externally are limited. The application’s documentation in this respect is non-existent, but there is no AppleScript support, and no details about command line support, URL scheme support, or any watch folders. One thing Dropzone does have however is Shortcuts support.
Building a Shortcut
I knew that I could trigger a shortcut from Automator via several means, so I decided to start the build at the Shortcuts end of things.
Shortcut support for Dropzone includes an Add to Drop Bar action, so that was the starting point. This action accepts a file, so I just needed Automator to pass in the PDF file to the shortcut. However, that wasn’t something so easy to do. In fact, I knew Automator would be providing a file path, so I decided to put a path to file (object) conversion into the shortcut.
By using the Get File from Folder action, I could specify a file in a folder to pass to the Dropzone action. The frustrating thing is that the Get File from Folder action is based on relative folder paths. I’m not 100% sure how the folder specification fares between devices, and given note everyone’s OS drive will be named identically, I opted to specify the root level “Users” folder and then pass in the folder path preceded by a
.. to indicate the OS should navigate one level down and then follow the path.
I did try this with the
System folder too, but I got some errors trying that whereas the
Users folder seemed to work as expected in my testing.
At the end, the shortcut runs a command line instruction to play a standard macOS sound. This just acts as an audible indicator the operation has completed. I generally find the audible cues more effective than standard visual notification, or disruptive as less-standard ones tend to be.
- Download Shortcut: Add to Dropzone Drop Bar
Building the Print Plugin
When creating a new automation in Automator, one of the options is for a Print Plugin.
To this automation I added a single Run Shell Script step.
An important point to note here is that I have explicitly set the step to pass input as arguments as I use the first argument (
$1), the file path of the generated PDF, in the script.
mv "$1" $HOME/Desktop/
echo -n "$newpath" | shortcuts run "Add to Dropzone Drop Bar"
The first line of the script moves the file to my Desktop. I chose to do this because later on, once I have made use of the PDF, if I have not “used up” the PDF in terms of processing, I can easily find and delete it. If you want to build your own version of the plugin, you can designate and alternative location - e.g. a dedicated folder in your Documents folder.
The second line builds a file path to the new file location and assigns it to the variable
The third line pipes that file path into the Shortcuts command line utility and runs the Add to Dropzone Drop Bar, passing in the file path as its input.
The plugin was named and saved, and after that it shows in the PDF menu in the print dialog.
- Download Automator Print Plugin: Add to Dropzone Drop Bar (extract ZIP file contents for workflow)
And that’s it. We have a multi-component solution to reduce that little bit of friction.
As noted, I expect to need to revisit this when Automator is to be decommissioned, but until then, I have a pretty easy way to output content as a PDF ready for redistribution via Dropzone.
Reach out on Mastodon (@email@example.com), and let me know if you build your own print plugin based on this, and how you have modified it.