How to PDF make searchable API in JavaScript with PDF.co Web API

This tutorial will show how to PDF make searchable API in JavaScript

These source code samples are listed and grouped by their programming language and functions they use. PDF.co 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 and you can use it to PDF make searchable API with JavaScript.

This rich sample source code in JavaScript for PDF.co Web API includes the number of functions and options you should do calling the API to PDF make searchable API. Just copy and paste the code into your JavaScript application’s code and follow the instruction. You can use these JavaScript sample examples in one or many applications.

ByteScout free trial version is available for download from our website. It includes all these programming tutorials along with source code samples.

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

MakeSearchablePdfFromFile.js
      
/*jshint esversion: 6 */ var https = require("https"); var path = require("path"); 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 https://app.pdf.co/documentation/api const API_KEY = "***********************************"; // Source PDF file 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 = ""; // OCR language. "eng", "fra", "deu", "spa" supported currently. Let us know if you need more. const Language = "eng"; // Destination PDF file name const DestinationFile = "./result.pdf"; // Prepare URL for `Make Searchable PDF` API endpoint var query = `https://api.pdf.co/v1/pdf/makesearchable`; let reqOptions = { uri: query, headers: { "x-api-key": API_KEY }, formData: { name: path.basename(DestinationFile), password: Password, pages: Pages, lang: Language, file: fs.createReadStream(SourceFile) } }; // Send request request.post(reqOptions, function (error, response, body) { if (error) { return console.error("Error: ", error); } // Parse JSON response let data = JSON.parse(body); if (data.error == false) { // Download PDF file var file = fs.createWriteStream(DestinationFile); https.get(data.url, (response2) => { response2.pipe(file) .on("close", () => { console.log(`Generated PDF file saved as "${DestinationFile}" file.`); }); }); } else { // Service reported error console.log("Error: " + data.message); } });

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

VIDEO

ON-PREMISE VERSION INFORMATION

Get 60 Day Free Trial or Visit PDF.co Web API Home Page

Explore PDF.co Web API Documentation

Get PDF.co Web API Free Training

WEB API

Get Your Free API Key

Explore Web API Documentation

Related Samples: