PDF to HTML in Node.js

This page describes how to convert PDF to HTML 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.

Installation

The Node.js API client library provides easy access to the Pdfcrowd API. No third-party libraries are required.

Install the client library from npm
npm install pdfcrowd

We also offer other installation options.

Authentication

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:

  • Username: demo
  • API key: ce544b6ea52a5621fb9d55f8b542d14d

To get your personal API credentials, you can start a free API trial or buy the API license.

API Method Reference

Refer to the PDF to HTML Node.js Reference for a description of all API methods.

Code Examples

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.PdfToHtmlClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// run the conversion and write the result to a file
client.convertFileToFile(
    "/path/to/logo.pdf",
    "logo.html",
    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.PdfToHtmlClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// run the conversion and write the result to a file
client.convertUrlToFile(
    "https://pdfcrowd.com/static/pdf/apisamples/invoice.pdf",
    "invoice.html",
    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.PdfToHtmlClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// run the conversion and write the result to a file
client.convertRawDataToFile(
    fs.readFileSync("/path/to/hello_world.pdf"),
    "logo.html",
    function(err, fileName) {
        if (err) return console.error("Pdfcrowd Error: " + err);
        console.log("Success: the file was created " + fileName);
    });

Troubleshooting