This page describes how to convert PDF to text in Node.js using the cloud-based Pdfcrowd API. The API is easy to use and it takes only a few of lines of code to integrate it to your application.
The Node.js API client library provides easy access to the Pdfcrowd API. No third-party libraries are required.
Install the client library from npmnpm install pdfcrowd
We also offer other installation options.
The credentials to access the API are your Pdfcrowd username and the API key. You can try out the API without registering using the following demo credentials:
demo
ce544b6ea52a5621fb9d55f8b542d14d
To get your personal API credentials, you can start a free API trial or buy the API license.
Refer to the PDF to Text Node.js Reference for a description of all API methods.
Here are a few Node.js examples to get you started quickly with the API. See more examples.
var pdfcrowd = require("pdfcrowd"); // create the API client instance var client = new pdfcrowd.PdfToTextClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d"); // run the conversion and write the result to a file client.convertFileToFile( "/path/to/invoice.pdf", "invoice.txt", function(err, fileName) { if (err) return console.error("Pdfcrowd Error: " + err); console.log("Success: the file was created " + fileName); });
var pdfcrowd = require("pdfcrowd"); // create the API client instance var client = new pdfcrowd.PdfToTextClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d"); // run the conversion and write the result to a file client.convertUrlToFile( "https://pdfcrowd.com/static/pdf/apisamples/invoice.pdf", "invoice.txt", function(err, fileName) { if (err) return console.error("Pdfcrowd Error: " + err); console.log("Success: the file was created " + fileName); });
var pdfcrowd = require("pdfcrowd"); var fs = require("fs"); // create the API client instance var client = new pdfcrowd.PdfToTextClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d"); // run the conversion and write the result to a file client.convertRawDataToFile( fs.readFileSync("/path/to/hello_world.pdf"), "invoice.txt", function(err, fileName) { if (err) return console.error("Pdfcrowd Error: " + err); console.log("Success: the file was created " + fileName); });