How to PDF text search API in JavaScript using Web API

How to PDF text search API in JavaScript

PDF text search API is easy to implement in JavaScript if you use these source codes below. Want to PDF text search API in your JavaScript app? Web API is designed for it. Web API is the Rest API that provides set of data extraction functions, tools for documents manipulation, splitting and merging of pdf files. Includes built-in OCR, images recognition, can generate and read barcodes from images, scans and pdf.

The SDK samples like this one below explain how to quickly make your application do PDF text search API in JavaScript with the help of Web API. In order to implement the functionality, you should copy and paste this code for JavaScript below into your code editor with your app, compile and run your application. You can use these JavaScript sample examples in one or many applications. Web API free trial version is available on our website. JavaScript and other programming languages are supported.

Try Web API today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

var fs = require("fs"); // `request` module is required for file upload. // Use "npm install request" command to install. var request = require("request"); // The authentication key (API Key). // Get your own by registering at const API_KEY = "***********************************"; // Source file name const SourceFile = "./sample.pdf"; // Comma-separated list of page indices (or ranges) to process. Leave empty for all pages. Example: '0,2-5,7-'. const Pages = ""; // PDF document password. Leave empty for unprotected documents. const Password = ""; // Search string. const SearchString = '[4-9][0-9].[0-9][0-9]'; // Regular expression to find numbers in format dd.dd and between 40.00 to 99.99 // Enable regular expressions (Regex) const RegexSearch = 'True'; // Prepare URL for PDF text search API call. // See documentation: var query = ``; let reqOptions = { uri: query, headers: { "x-api-key": API_KEY }, formData: { password: Password, pages: Pages, searchString: SearchString, regexSearch: RegexSearch, file: fs.createReadStream(SourceFile) } }; // Send request request.get(reqOptions, function (error, response, body) { if (error) { return console.error("Error: ", error); } // Parse JSON response let data = JSON.parse(body); for (let index = 0; index < data.body.length; index++) { const element = data.body[index]; console.log("Found text " + element["text"] + " at coordinates " + element["left"] + ", " + element["top"]); } });

Try Web API today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)



Get 60 Day Free Trial or Visit Web API Home Page

Explore Web API Documentation

Get Web API Free Training


Get Your Free API Key

Explore Web API Documentation

Related Samples: