How to get PDF info from file (node for PDF information API in JavaScript using PDF.co Web API

How to get PDF info from file (node for PDF information API in JavaScript: How To Tutorial

Every ByteScout tool contains example JavaScript source codes that you can find here or in the folder with installed ByteScout product. PDF.co Web API was made to help with PDF information API in JavaScript. PDF.co Web API is the Web API with a set of tools for documents manipulation, data conversion, data extraction, splitting and merging of documents. Includes image recognition, built-in OCR, barcode generation and barcode decoders to decode bar codes from scans, pictures and pdf.

The SDK samples like this one below explain how to quickly make your application do PDF information API in JavaScript with the help of PDF.co Web API. Follow the instruction and copy – paste code for JavaScript into your project’s code editor. You can use these JavaScript sample examples in one or many applications.

Trial version of ByteScout is available for free download from our website. This and other source code samples for JavaScript and other programming languages are available.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

GetPdfInfoFromFile.js
      
/*jshint esversion: 6 */ 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 to get information const SourceFile = "./sample.pdf"; // Prepare URL for `PDF Info` API call var query = `https://api.pdf.co/v1/pdf/info`; let reqOptions = { uri: query, headers: { "x-api-key": API_KEY }, formData: { 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) { // Display PDF document information for (var key in data.info) { console.log(`${key}: ${data.info[key]}`); } } else { // Service reported error console.log("Error: " + data.message); } });

ON-PREMISE OFFLINE SDK

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

Explore PDF.co Web API Documentation

Explore Samples

Sign Up for PDF.co Web API Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

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

Explore PDF.co Web API Documentation

Explore Samples

Sign Up for PDF.co Web API Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Related Samples: