How to Extract Tables Containing Text from PDF using PDF.co and Make
In this tutorial, we will show you how to extract tables containing text from PDF using PDF.co and Make.
We will use this 2-page sample PDF and extract the table items that span in two pages.
IN THIS TUTORIAL
Step 1: Create A Scenario
First, click on the Create A Scenario button in the upper right corner of your dashboard.
Step 2: Google Drive App
Now, you will Create a New Scenario, click the Google Drive App as our App event.
Step 3: Download a File
Under Google Drive, select Download a File so we can use the file in the PDF.co module.
Step 4: Google Drive Connection
Under Google Drive Connection, we will create a connection to Google Drive.
- In the Enter a File ID field, choose the Select from the list to fill out your File ID.
- For the Choose a Drive field, select the My Drive.
- Under the File ID field, choose the folder where your file resides.
Step 5: PDF.co App
Let’s add another module. This time select PDF.co so we can call the module to extract table contents.
Step 6: Parse a Document
Under PDF.co, select the Parse a Document module to automatically read invoices, reports, orders, statements, and other documents with fields and tables.
Step 7: Configure PDF.co Module
Under PDF.co Connection, you will add your PDF.co connection.
- In the Input File field, select the Import a file from the URL.
- Under the URL field, input the URL of the source PDF, image, or document.
- Enter the template ID in the Document Parser Template ID to parse a document in your file.
Step 8: Parsed Table Output
Great! The test was successful. In the inline result, you will see all the table line items from 1 to 45.
Step 9: Create Document Parser Template
We will show you how to create the template to extract a multi-page table.
Step 1: Load Test PDF
Click the Load Test PDF or Image button to open the PDF document that you will use for your template.
Step 2: Add FIELD based on TEXT SEARCH
Next, click on the Add Object button on the upper left corner and select Add FIELD based on TEXT SEARCH.
Step 3: Name and Regex
You can rename the object in the Name field. Make sure to check the Regex box when using any Text Search objects.
Step 4: Add Total Object Expression
You can either add expressions in the Expression field or directly in the Edit Template window.
Use the expression TOTAL{{Spaces}}({{Number}})
to parse the Total.
Step 5: Add TABLE Field Based on TEXT SEARCH
Now, click on the Add Object button and select the Add TABLE Field based on TEXT SEARCH.
Step 6: Add Table Object Expression
In the Edit Template window, add the start and end expressions as well as necessary rows and columns. Then, set the multipage to true.
{
"start": {
"expression": "Item{{Spaces}}Description{{Spaces}}Price",
"regex": true
},
"end": {
"expression": "TOTAL{{Spaces}}{{Number}}",
"regex": true
},
"row": {
"expression": "{{LineStart}}{{Spaces}}(?{{Digits}}){{Spaces}}(?{{SentenceWithSingleSpaces}}){{Spaces}}(?{{Number}}){{Spaces}}(?{{Digits}}){{Spaces}}(?{{Number}})",
"regex": true
},
"columns": [
{
"name": "itemNo",
"dataType": "integer"
},
{
"name": "description",
"dataType": "string"
},
{
"name": "price",
"dataType": "decimal"
},
{
"name": "qty",
"dataType": "integer"
},
{
"name": "extPrice",
"dataType": "decimal"
}
],
"multipage": true
}
Then Run the template to make sure there are no errors.
Step 7: Parsed Table Output
Here’s the parsed table line items output.
In this tutorial, you learned how to extract tables containing text from PDF using the PDF.co Parse a Document module in Integromat. You also learned how to create a Document Parser template.