How to Rasterize a PDF in Power Automate

Cloudmersive
5 min readOct 17, 2024

--

If we’re looking to make a PDF’s text content less easily accessible to document viewers, there’s a simple solution we can employ: rasterization.

PDF rasterization is the process of converting a vector PDF (or any text-based PDF) to an image-based PDF. The content we see in a rasterized PDF document is entirely comprised of pixels — meaning it’s impossible copy text directly from that document without using an OCR (Optical Character Recognition) solution. Vector PDFs and other text-based PDFs store plain text information in the document along with vector graphics, links, and other media objects.

Rasterizing a PDF chiefly improves its security by drastically reducing (and, for media assets like videos, completely eliminating) the accessibility of its various contents. In some cases, rasterizing a vector PDF can also improve its loading speed in browsers & other PDF reader applications (at the cost of removing the scalability of its vector graphics).

Rasterize PDFs in Power Automate

In Power Automate, we can quickly and easily rasterize PDF documents before sharing those files via email, storing them elsewhere in our system, or performing any other workflow actions.

In this article, we’ll walk through an example flow that rasterizes a text-based PDF and emails the resulting document to a recipient. We’ll build an instant cloud flow in this case so we can fully control our data when we run our test.

We’ll begin our flow by retrieving our PDF file’s metadata with a Get file metadata action. This step makes important information — including the file ID and the file name — available as dynamic content in our flow.

Next, we’ll add a Get file content action and use the File ID (Id) to retrieve our PDF file bytes.

We’ll now add in our PDF rasterization action. To find this action, we’ll search for Cloudmersive connectors and locate the Cloudmersive PDF connector with the pink logo.

We’ll then click “See more” to view the actions list, and from here, we’ll search for an action called Rasterize a PDF to an image-based PDF. We’ll go ahead and select it once we find it.

We’ll notice this is a premium (rather than built-in) action — and that means we’ll need a premium Power Automate license to access it. We can use it at no additional cost, however, with a free API key. To get a free API key, we can simply head to the Cloudmersive website and create a free account.

After we’ve created our connection, we’ll configure this action’s request parameters by adding our file bytes and file name into their respective fields. It doesn’t actually matter if we enter our file’s real name here — but we can easily grab that (with or without the file extension) thanks to our Get file metadata action.

Now we’ll wrap up our flow by adding a Send an email action. In my example flow, I’ll be using the Send an email (V2) action from the Office 365 Outlook connector.

I’ll attach my PDF’s file bytes by 1) opening the Send an email (V2) advanced parameters and 2) adding a new item in the Attachments parameter. Here, I’ll use the original file name (including the extension) and my rasterized PDF file bytes to create the attachment.

Once we’re done configuring our email action, we’ll save our flow and run a test. This will send the email to our target recipient (in my example flow, I’m sending an email to myself).

When we open the new PDF, we’ll be able to tell it’s rasterized by selecting Settings > View document properties and checking if the Author, Creator, and PDF producer are listed as imagemagick.org.

In my example, the original PDF Author held my name, and the Creator and Producer were listed as Microsoft Word for Microsoft 365 (the application in which the document was original created and exported from).

There’s a way we can set the metadata for our newly rasterized document (or any other PDF), too — but we’ll cover that process in another article.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet