In this tutorial, we will show you how to extract bold text from PDF in JavaScript using PDF.co Web API. Below is the image of the source PDF and the extracted bold text output in XML format.

Source PDF and XML Output
Source PDF and XML Output

Step 1: Source File and JavaScript Code

To begin, open your Visual Studio app and save the following files:

Step 2: Install Request Module

Next, install the request module for file upload. Type the npm install requests in the terminal.

Step 3: PDF.co API Key

In line 13, add your API key inside the double quote. You can get the PDF.co API Key in your dashboard here.

PDF.co API Key

Step 4: Source and Destination Files

In line 17, enter your source PDF file and type in your desired XML output file name in line 23.

Source and Destination Files

Step 5: Run Program

Once you complete the setup. Let’s run the program by typing the node app.js in the terminal.

Extract Bold Text Demo

Here’s a quick demo to extract bold text from PDF.

Extract Bold Text Demo
Extract Bold Text Demo

In these tutorials, you learned how to extract bold text from PDF in JavaScript using PDF.co Web API. You learned how to install the requests module to run the program. You also learned how to use the PDF to XML Web API to extract bold text from PDF.