Step 1 – Source Code
To begin, open your favorite editor and save the following files:
Grab your copy of the sample PDF here.
Step 2 – Install Request
We will use the request module for file upload. Kindly type in
npm install request in your terminal.
Step 3 – Add API Key
In line 25, enter your PDF.co API Key. You can get your API Key in the PDF.co dashboard here.
Step 4 – Source and Destination Files
Let’s add the source file in line 28 and the destination file name in line 32. Aside from JSON, you can also extract the text in CSV and XML formats.
Step 5 – Add Template
In line 109, add the template name. The Document Parser supports both JSON and YML template formats.
For more information about Document Parser Template, check out this page.
Step 6 – Run Program
To run the program, type in
node app.js in the Terminal.
Step 7 – Extract Email Address Demo
Here’s a quick demo to parse an email address in a PDF from start to finish.