Skip to main content

Overview

In this guide, we’ll build a custom file parser to support PDF uploads using the PDFTables API to extract tables from PDFs.

Getting Started

For our example we’re importing users from a table in a PDF document. PDF Contents We’ll rely on PDFTables API to parse the PDF into a CSV string. Once we have a CSV string, we’ll use an additional external library, PapaParse, to parse the CSV string into a two dimensional array of data for Dromo to receive.
To use this demo you’ll need to get your own paid API key from PDFTables.

Adding the Custom Parser to Dromo

Dromo provides an interface for implementing custom file parsing. We need to specify the file extension(s) and the parsing logic that will be used to parse the file.

Implementing PDF Parsing Logic

Dromo passes a buffer: ArrayBuffer and fileName: string to the parseFile callback. We will use the buffer to create a file that we can POST to the PDFTables API.
If successful, the response.text() will contain a CSV string. Like this:
We need to convert this in to a two dimensional array. We’ll use PapaParse, a free package, to convert the string to the desired format.
Ensure that every line in the two dimensional array is the same length, then return the data.
We’re done! Let’s try it in Dromo and see how it works. Open the Dromo importer and observe the file extensions now include ‘pdf’. extensions include pdf image Drag and drop your PDF test file. Your data should be properly parsed and loaded. parsed pdf data

Full Complete Demo