Extract Tables from a PDF using Power Automate Desktop

One of my colleagues works in an HR team, where they receive a large number of PDF files containing Employee details of their organization. They wanted to extract the Employee details that are present in a tabular format and store them in an Excel worksheet.

To simplify the process, without manually adding data, I suggested using Power Automate desktop flow to extract tables and save them to an Excel worksheet.

This tutorial will explain how to extract a table from a PDF file using Power Automate Desktop and display it in a message box. Additionally, I will cover how to extract tables from a PDF File and display them in an Excel spreadsheet in Power Automate Desktop.

Extract a Table from PDF using Power Automate Desktop [Display in Message Box]

To explain this example, I will use the PDF “Employee Details” in my local system.

How to Extract a Table from a PDF by Power Automate

Here are the steps to extract a table from a PDF file :

  1. Open the Power Automate desktop app-> Click on the + New button -> Select Flow -> Provide a name for the flow in the Create a flow dialogue box. Then, click on the Create button.
New Extract Tables from PDF Power Automate Desktop
  1. Then, it will open a separate window where you can drag and drop the actions to the workspace designer.
Extract Tables from a PDF using Desktop flow
  1. Under Actions pane, search for “Extract tables from PDF” action. Drag and drop it to the workspace.
Extract tables from PDF Action Power Automate Desktop
  1. In the Extract tables from PDF action, set the below placed properties. Then, click on Save.
    • PDF file: Upload the PDF file from your local desktop by clicking the Select file icon.
    • Page(s) to extract: I will choose ‘Single’, as I have data table in single page.
    • Single page number: Provide the page number.
Power Automate Desktop Extract Tables from PDF
  1. Then, drag and drop the “For each” loop into the workspace, so that it iterates over items in a table. The value retrieved will be stored in the CurrentItem variable.
    • Value to iterate: Click on {x} -> Select variable from Excel.
Extract Tables from a PDF using Power Automate Desktop
  1. Inside the For each loop, search and add a “Display message” action to display the table data extracted from the PDF file. Set the properties and click on the Save button.
    • Message box title: Give a name for a message box.
    • Message to display: Click on {X} -> Expand CurrentItem variable -> Select .Data Table.
    • Message box icon: Choose the Information option.
Extract tables from Power Automate for Desktop
  1. Once it is done, save and run the flow. When the flow execution is completed, a message box displays the extracted table values. The screenshot below shows this.
Power Automate Desktop Extracting Tables from PDF

The above steps will extract the tables from a PDF file to a message box using Power Automate Desktop.

However, sometimes, you may need to convert the extracted table to an Excel file. To do so, follow the steps below.

Check out Connect Power Automate Desktop to Cloud using Direct connectivity

Extract Tables from a PDF to Excel by Power Automate Desktop

In this section, let’s see how to extract tables from a PDF to an Excel worksheet using Power Automate desktop.

Below is a PDF file containing two tables with the data on different pages. You can see the GIF placed below..

How to get PDF Table to Excel in Power Automate Desktop

I want to extract these two tables into separate Excel worksheets. To extract tables from a PDF file, you need to use the Extract tables from PDF action, where the row index of the extracted table starts with 0. Here, I have two tables in the PDF mentioned above, so the row index of the 2nd table will be 1.

As you already know, creating a flow in Power Automate desktop requires the steps outlined below.

  1. Drag and drop “Extract tables from PDF” action into workspace, set the below placed properties. Then, click on Save.
    • PDF file: Click on {x} -> Select a pdf file from your local system.
    • Page(s) to extract: Select the required option.

This action will produce a variable named ExtractedPDFTables.

Get PDF Tables using Power Automate Desktop
  1. Drag and drop “Launch Excel” from the Action pane on the Flow designer workspace window. Configure the parameters below. Then, click on Save.
    • Launch Excel: Select with a blank document option.
    • Make instance visible: Select the toggle button.
How to Extract tables from PDF with Power Automate desktop
  1. Next, add an action “Focus window”. Then, select By title and/or class option for the Find window mode parameter. Click the Save button.
    • Window title: Choose Book1 – Excel option.
Extract tables from PDF with Power Automate desktop
  1. After that, add a “Set window state” action. Set the properties below. Click on the Save button to add the action to the workspace.
    • Find window mode: Select the By title and/or class option.
    • Window title: Choose Book1 – Excel option.
    • Window state: Select the Maximized option.
How To Extract Tables From A PDF In Power Automate desktop
  1. Search for the variables under the Actions pane and drag and drop the “Set variable” action. Then, provide the information below. After that, click on the Save button.
    • I have renamed the variable produced to TableNumber.
    • Value: Enter the value to ‘0’.
PDF Automation in Power Automate Desktop
  1. Search and add “For each” loop, so that it will loop through all the items. The value retrieved will be stored into currentItem variable. Tap on Save button.
    • Value to iterate: Click on {X} -> Select ExtractedPDFTables variable.
Retrieve Tables From A PDF In Power Automate desktop
  1. Inside the For each loop, drag and drop the “Add new worksheet” action. Provide below properties. Then, Save the action.
    • Excel instance: By default, it will be selected.
    • New worksheet name: Select TableNumber variable.
    • Add worksheet as: Select Last worksheet option from drop-down.
Power Automate Desktop PDF tables Extraction
  1. Then, add “Write to Excel worksheet” action. Configure the below properties. This action will add the column header values to Excel. Save the action.
    • Value to write: Insert the below code
    • Write mode: Select On currently active cell option.
%ExtractedPDFTables[TableNumber].datatable.ColumnHeadersRow%
PDF table data extraction in Microsoft Power Automate desktop
  1. Next, add a “Get first free row on column from Excel worksheet” action. Enter the value of ‘1’ in the Column parameter. Here, it will produce FirstFreeRowOnColumn variable. Save the action.
Get table from PDF Send to EXCEL with Power Automate desktop
  1. Now, add another “Write to Excel worksheet” action to add the table data. Set the required properties and save the action.
    • Value to write: %ExtractedPDFTables[TableNumber].datatable%
    • Write mode: Select On specified cell option.
    • Column: Enter value as 1.
    • Row: Choose FirstFreeRowOnColumn variable.
How to Extract Data tables from PDF to Excel by Power Automate Desktop
  1. In the final step, take the Increase variable action. This will make the loop rerun until a specific value is provided [Increase by 1]. I have taken a PDF with two tables, so I want to increase the variable value by 1. Click Save.
PDF Table Extraction Using Power Automate
  1. Now, the flow is ready to save. Click on the Save icon and run the flow.

When the flow runs, you can see the row index of an extracted table in the ExtractPDFTable variable. For the zero index, the flow will execute the first table, and for the 1-row index, the flow will execute the second table. If you have more tables in your PDF, increase the set variable number.

Extract PDF Tables in Power Automate Desktop

After the flow executes successfully, you can see that the tables from the PDF file are extracted and stored in two different Excel worksheets.

Power Automate desktop extract table from pdf to excel
Extract table from pdf file in Power Automate desktop

This is all about how to extract tables from a PDF file using Power Automate Desktop.

In this tutorial, I have explained how to extract tables from a PDF file using Power Automate Desktop (PAD). I hope you found this article helpful. Please let me know about your suggestions in the comments section.

You may also like the following tutorials:

>

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…