How to Convert PDF to Base64 Using Power Automate?

I recently received a request to convert PDF files to Base64 using Power Automate. The requirement is that when a user uploads a PDF file to a SharePoint Document library, that specific PDF should be converted into Base64 format and stored as a text file in the same library.

This Power Automate Tutorial will show you how to convert PDF to Base64 using Power Automate.

Convert PDF to Base64 Using Power Automate

Before creating flow, ensure you have a SharePoint Document Library like the screenshot below.

Sharepoint PDF to base64

To convert the PDF file to Base64 using Power Automate, follow the steps below:

1. Create an automated cloud flow. Give the flow name and select the trigger ‘When a file is created (properties only).’ Click on Create.

Convert PDF to Base64 using Power Automate

2. Now, Provide the mandatory fields, such as Site Address and Library Name.

Power Automate PDF to base64

3. Next, we will add another action, Get file content, which retrieves the contents of a file using its identifier.

To do this, click the + icon to add Get file content. After that, select the SharePoint Site address and set the File identifier as Identifier (Select the value from dynamic content).

How to convert to base64 in Power Automate

4. Next, add a condition action to check whether the uploaded file is a PDF or not.

To do this, click the + icon to add a Condition. Set the properties such as File name with extension contains .pdf / File name with extension ends with .pdf, as in the screenshot below.

How to convert PDF file to Base64 in Microsoft Power Automate

5. Click the + icon to add the Compose action inside the True section. Inside the input box, click the fx button to enter the expression below.

base64(body('Get_file_content')['$content'])

This base64 function converts PDF to base64. Then click the Add button.

How to convert Base 64 from PDF in Power Automate

6. After converting PDF to base64, add an action to store text files in a SharePoint library.

To do this, click the + icon to add the Create file (Under SharePoint connector). Provide the values to the mandatory properties such as Site Address, Folder Path, File Name, and File Content.

The file name must include the .txt extension, and the file content uses the dynamic content from the Compose action, ‘Output.’

How to Convert PDF to Base64 using Power Automate

Let’s save the flow and test it to see how it works. Click on Save > Test > Manually > Run flow.

For testing purposes, I uploaded a PDF file to the document library, and then after some time, you can see a text file will be added to the same library as shown below.

Convert PDF file to Base64 using Power Automate

I hope this article helped you to know how to convert PDF to base64 using Power Automate.

Also, you may like some more Power Automate articles:

>

Build a High-Performance Project Management Site in SharePoint Online

User registration Power Apps canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

Power Platform Tutorial FREE PDF Download

FREE Power Platform Tutorial PDF

Download 135 Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…