How to Add Annotations to PDF Documents in Power Automate
We might think of PDF annotations as equivalent to comments in Word documents and other Open Office files, but in truth they have a broader-serving purpose. We can apply annotations to PDF documents like sticky notes; to make announcements, provide general instructions to document viewers, and more.
In Power Automate, we can create no-code programmatic workflows which place annotations in specific locations on a number of different PDF documents at once. These annotations can serve as reminders or instructions for folks eventually viewing the PDFs and utilizing their contents.
In this article, we’ll run through a quick example flow that applies one standard annotation across multiple PDF documents living in a single folder. We’ll end up with a consistent message in each PDF that remains a part of that document for the foreseeable future.
We’ll build a manually triggered, instant cloud flow in this case so we can have full control over our data when we eventually run our test.
Since we’re targeting a folder full of PDF documents in this workflow, we’ll start by incorporating a List files in folder (OneDrive for Business) or List files (SharePoint) action. My files live in OneDrive, so I’ll be using the former option in my flow.
This action retrieves some useful metadata about files living in our target folder — including the file names and file IDs. In our next step, we’ll use a Get file content action to retrieve our PDFs’ file bytes using the file IDs.
We’ll notice Power Automate wrapped our Get file content action in a For each control; this is to account for the array of files in our target folder.
We’ll now add our annotation action within the For each control. We’ll search for Cloudmersive connectors, and we’ll scroll down to find the Cloudmersive PDF connector on this list.
We’ll click “See more” to view the actions list, and once we’re there, we’ll find the action we’re looking for right at the top of the list. It’s called Add one or more PDF annotations, comments in the PDF document.
Once we select this action, it’ll be time to create our Cloudmersive PDF connection.
It’s important to note that we’ll need a premium Power Automate license to access this (and any other) Cloudmersive connector — but as long as we have that, we can use these connectors at no additional cost with a free API key. Free API keys allow a limit of 800 API calls per month, and we can get one by signing up for a free account on the Cloudmersive website.
After we’ve created our connection, we’ll open the advanced parameters and configure our Add annotations request. In the bottom parameter, we’ll enter file bytes retrieved by our Get file content action.
Within the Request/AnnotationsToAdd parameter, we’ll add a new item and begin customizing the annotations we’re adding to our document.
Here, we have the option to customize every aspect of the annotation we’ll add to each PDF in our folder, including the index, type, creation date, height, left x coordinate value, page number, subject, title, and more.
We’ll first handle the text portion of our annotation. In the below example, I’ve added sample text contents along with a sample title and subject.
Next, we’ll decide the height and width of our annotation box. For reference, distances within a PDF are measured by a points system in which 1 inch = 72 points, and the standard PDF paper size is 8.5 x 11 inches (612 x 792 points).
To end up with a “normal” annotation box size, we’ll use a width between 100–150 points and a height between 50–70 points.
To plot our annotation on the PDF page matrix, we’ll first need to think about where we want our annotation to show up. In my example, I’ll place a PDF annotation on the right-hand margin of the page about halfway down from the top. To do this, I’ll add a Left X value of 550 points, and a Top Y value of 400 points. I’ll then add 1 in the Pagenumber parameter and 0 in the Annotationindex parameter.
We’ll now add a Create file action to our flow and save the annotated versions of our PDFs in a new folder. Thanks to our List files in folder or List files actions, we’ll be able to dynamically re-use the original file names.
We’ll now save and test our flow. When it finishes running, we’ll find our annotated PDFs in the folder we specified.
When we open one of our annotated PDFs, we’ll find a hover-over annotation box in the spot we plotted on our page.
And just like that, we’re all done! We’ve created a standard annotation for every PDF in a specific folder that readers can see & open when the view the document’s contents.