HTML to PDF API - Node.js

Learn how to convert web pages and HTML documents to PDF in Node.js using the Pdfcrowd API v2. The API is easy to use and the integration takes only a couple of lines of code.

Installation

Install the client library from npm
npm install pdfcrowd

Learn more about other install options.

Authentication

Authentication is needed in order to use the Pdfcrowd API. The credentials used for accessing the API are your Pdfcrowd username and the API key.
Sign up for a Free Trial

Examples

var pdfcrowd = require("pdfcrowd");

// create the API client instance
var client = new pdfcrowd.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// run the conversion and write the result to a file
client.convertUrlToFile(
    "http://www.example.com",
    "example.pdf",
    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.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// use predefined callback for saving to a file
var callbacks = pdfcrowd.saveToFile("example.pdf");

// set custom error callback
callbacks.error = function(errMessage, statusCode) {
    if(statusCode) {
        console.error("Pdfcrowd Error: " + statusCode + " - " + errMessage);
    } else {
        console.error("Pdfcrowd Error: " + errMessage);
    }
};

// run the conversion and write the result to a file
client.convertUrl("http://www.example.com", callbacks);
var pdfcrowd = require("pdfcrowd");

// create the API client instance
var client = new pdfcrowd.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

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

// use predefined callback for saving to a file
var callbacks = pdfcrowd.saveToFile("MyLayout.pdf");

// set custom error callback
callbacks.error = function(errMessage, statusCode) {
    if(statusCode) {
        console.error("Pdfcrowd Error: " + statusCode + " - " + errMessage);
    } else {
        console.error("Pdfcrowd Error: " + errMessage);
    }
};

// run the conversion and write the result to a file
client.convertFile("/path/to/MyLayout.html", callbacks);
var pdfcrowd = require("pdfcrowd");

// create the API client instance
var client = new pdfcrowd.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// run the conversion and write the result to a file
client.convertStringToFile(
    "<html><body><h1>Hello World!</h1></body></html>",
    "HelloWorld.pdf",
    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.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// use predefined callback for saving to a file
var callbacks = pdfcrowd.saveToFile("HelloWorld.pdf");

// set custom error callback
callbacks.error = function(errMessage, statusCode) {
    if(statusCode) {
        console.error("Pdfcrowd Error: " + statusCode + " - " + errMessage);
    } else {
        console.error("Pdfcrowd Error: " + errMessage);
    }
};

// run the conversion and write the result to a file
client.convertString("<html><body><h1>Hello World!</h1></body></html>", callbacks);
var pdfcrowd = require("pdfcrowd");

// create the API client instance
var client = new pdfcrowd.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// configure the conversion
try {
    client.setDebugLog(true);
} catch(why) {
    console.error("Pdfcrowd Error: " + why);
    console.error("Pdfcrowd Error Code: " + why.getCode());
    console.error("Pdfcrowd Error Message: " + why.getMessage());
    process.exit(1);
}

// run the conversion and write the result to a file
client.convertFileToFile(
    "/path/to/MyLayout.html",
    "MyLayout.pdf",
    function(err, fileName) {
        if (err) return console.error("Pdfcrowd Error: " + err);
        console.log("Success: the file was created " + fileName);
        
        // print URL to the debug log
        console.log("Debug log url: " + client.getDebugLogUrl());
        
        // print the number of available conversion credits in your account
        console.log("Remaining credit count: " + client.getRemainingCreditCount());
        
        // print the number of credits consumed by the conversion
        console.log("Consumed credit count: " + client.getConsumedCreditCount());
        
        // print the unique ID of the conversion
        console.log("Job id: " + client.getJobId());
        
        // print the total number of pages in the output document
        console.log("Page count: " + client.getPageCount());
        
        // print the size of the output in bytes
        console.log("Output size: " + client.getOutputSize());
    });

Advanced Examples

var pdfcrowd = require("pdfcrowd");

// create the API client instance
var client = new pdfcrowd.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// configure the conversion
try {
    client.setPageSize("Letter");
    client.setOrientation("landscape");
    client.setNoMargins(true);
} catch(why) {
    console.error("Pdfcrowd Error: " + why);
    console.error("Pdfcrowd Error Code: " + why.getCode());
    console.error("Pdfcrowd Error Message: " + why.getMessage());
    process.exit(1);
}

// run the conversion and write the result to a file
client.convertUrlToFile(
    "http://www.example.com",
    "letter_landscape.pdf",
    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.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// configure the conversion
try {
    client.setHeaderHeight("15mm");
    client.setFooterHeight("10mm");
    client.setHeaderHtml("<a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a>");
    client.setFooterHtml("<center><span class='pdfcrowd-page-number'></span></center>");
    client.setMarginTop("0mm");
    client.setMarginBottom("0mm");
} catch(why) {
    console.error("Pdfcrowd Error: " + why);
    console.error("Pdfcrowd Error Code: " + why.getCode());
    console.error("Pdfcrowd Error Message: " + why.getMessage());
    process.exit(1);
}

// run the conversion and write the result to a file
client.convertUrlToFile(
    "http://www.example.com",
    "header_footer.pdf",
    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.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// configure the conversion
try {
    client.setScaleFactor(300);
} catch(why) {
    console.error("Pdfcrowd Error: " + why);
    console.error("Pdfcrowd Error Code: " + why.getCode());
    console.error("Pdfcrowd Error Message: " + why.getMessage());
    process.exit(1);
}

// run the conversion and write the result to a file
client.convertUrlToFile(
    "http://www.example.com",
    "zoom_300.pdf",
    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.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// configure the conversion
try {
    client.setAuthor("Pdfcrowd");
    client.setTitle("Hello");
    client.setSubject("Demo");
    client.setKeywords("Pdfcrowd,demo");
} catch(why) {
    console.error("Pdfcrowd Error: " + why);
    console.error("Pdfcrowd Error Code: " + why.getCode());
    console.error("Pdfcrowd Error Message: " + why.getMessage());
    process.exit(1);
}

// run the conversion and write the result to a file
client.convertUrlToFile(
    "http://www.example.com",
    "with_metadata.pdf",
    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.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// configure the conversion
try {
    client.setPageLayout("single-page");
    client.setPageMode("full-screen");
    client.setInitialZoomType("fit-page");
    client.setOrientation("landscape");
    client.setNoMargins(true);
} catch(why) {
    console.error("Pdfcrowd Error: " + why);
    console.error("Pdfcrowd Error Code: " + why.getCode());
    console.error("Pdfcrowd Error Message: " + why.getMessage());
    process.exit(1);
}

// run the conversion and write the result to a file
client.convertUrlToFile(
    "https://pdfcrowd.com/doc/api/",
    "slide_show.pdf",
    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.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// configure the conversion
try {
    client.setElementToConvert("#main");
} catch(why) {
    console.error("Pdfcrowd Error: " + why);
    console.error("Pdfcrowd Error Code: " + why.getCode());
    console.error("Pdfcrowd Error Message: " + why.getMessage());
    process.exit(1);
}

// run the conversion and write the result to a file
client.convertUrlToFile(
    "https://pdfcrowd.com/doc/api/",
    "html_part.pdf",
    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.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// configure the conversion
try {
    client.setCustomJavascript("el=document.createElement('h2'); el.textContent='Hello from Pdfcrowd API'; el.style.color='red'; el_before=document.getElementsByTagName('h1')[0]; el_before.parentNode.insertBefore(el, el_before.nextSibling)");
} catch(why) {
    console.error("Pdfcrowd Error: " + why);
    console.error("Pdfcrowd Error Code: " + why.getCode());
    console.error("Pdfcrowd Error Message: " + why.getMessage());
    process.exit(1);
}

// run the conversion and write the result to a file
client.convertUrlToFile(
    "http://www.example.com",
    "html_inject.pdf",
    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.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// configure the conversion
try {
    client.setViewportWidth(992);
    client.setRenderingMode("viewport");
    client.setSmartScalingMode("viewport-fit");
    client.setNoMargins(true);
} catch(why) {
    console.error("Pdfcrowd Error: " + why);
    console.error("Pdfcrowd Error Code: " + why.getCode());
    console.error("Pdfcrowd Error Message: " + why.getMessage());
    process.exit(1);
}

// run the conversion and write the result to a file
client.convertUrlToFile(
    "https://getbootstrap.com/",
    "bootstrap.pdf",
    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.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// configure the conversion
try {
    client.setCustomJavascript("libPdfcrowd.highlightHtmlElements({backgroundColor: 'rgba(255, 191, 0, 0.1)', borderColor:null})");
} catch(why) {
    console.error("Pdfcrowd Error: " + why);
    console.error("Pdfcrowd Error Code: " + why.getCode());
    console.error("Pdfcrowd Error Message: " + why.getMessage());
    process.exit(1);
}

// run the conversion and write the result to a file
client.convertUrlToFile(
    "http://www.example.com",
    "highlight_background.pdf",
    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.HtmlToPdfClient("demo", "ce544b6ea52a5621fb9d55f8b542d14d");

// configure the conversion
try {
    client.setCustomJavascript("libPdfcrowd.highlightHtmlElements({borderColor: 'orange', backgroundColor: null, padding: '4px', margin: '4px'})");
} catch(why) {
    console.error("Pdfcrowd Error: " + why);
    console.error("Pdfcrowd Error Code: " + why.getCode());
    console.error("Pdfcrowd Error Message: " + why.getMessage());
    process.exit(1);
}

// run the conversion and write the result to a file
client.convertUrlToFile(
    "http://www.example.com",
    "highlight_borders.pdf",
    function(err, fileName) {
        if (err) return console.error("Pdfcrowd Error: " + err);
        console.log("Success: the file was created " + fileName);
    });

Web Server Integration

Check out complete examples in our pdfcrowd-examples Github repository:

Common Customizations

The API lets you convert a web page, a local HTML file, or a string containing HTML. The result of the conversion can be stored to a local file, to a stream object or to a variable. See the conversion input section for more details.

The best way to start with the API is to choose one of the examples and once you get it working, you can further customize the code. You can find the most common customizations in the table below.

Page size Change the page size with setPageSize or setPageDimensions. Pass -1 to setPageHeight to get a single page PDF containing the whole document.
Page orientation Change the page orientation to landscape with setOrientation.
Page margins Adjust the page margins with setPageMargins.
Headers and footers Add headers and footers with setHeaderHtml and setFooterHtml. Set the height with setFooterHeight and setHeaderHeight.
Zoom Scale the HTML contents with setScaleFactor.
Hide or remove elements You can use the following classes in your HTML code to hide or remove elements from the output:
  • pdfcrowd-remove - sets display:none!important on the element
  • pdfcrowd-hide - sets visibility:hidden!important on the element
Use @media print You can switch to the print version of the page (if it exists) with setUsePrintMedia.
Force page break You can force a page break with
<div style="page-break-before:always"></div>
Avoid page break You can avoid a page break inside an element with the following CSS
th, td, img { page-break-inside:avoid }
Run custom JavaScript You can use setOnLoadJavascript or setCustomJavascript to alter the HTML contents with a custom JavaScript. In addition to the standard browser APIs, the custom JavaScript code can use helper functions from our JavaScript library.

Error Handling

try {
    // call the API 
}
catch(why) {
    // print error
    console.error("Pdfcrowd Error: " + why);

    // print just error code
    console.error("Pdfcrowd Error Code: " + why.getCode());

    // print just error message
    console.error("Pdfcrowd Error Message: " + why.getMessage());

    // or handle the error in your way
}

Troubleshooting

  • Check API Status Codes in case of the error code is returned.
  • You can use setDebugLog and getDebugLogUrl to get detailed info about the conversion, such as conversion errors, time, console output.
  • You can use our JavaScript library to resolve rendering problems, such as missing content or blank pages.
    Just use setCustomJavascript with libPdfcrowd.highlightHtmlElements method call to visualize all HTML elements. See the example and helper JavaScript library documentation.
  • Take a look at the FAQ section.

API Reference - class HtmlToPdfClient

Conversion from HTML to PDF. All setter methods return HtmlToPdfClient object unless otherwise specified.

Constructor

function HtmlToPdfClient(userName, apiKey)
Constructor for the Pdfcrowd API client.
userName
Your username at Pdfcrowd.
apiKey
Your API key.

 

Conversion Input

function convertUrl(url, callbacks)
Convert a web page.
url
The address of the web page to convert.
The supported protocols are http:// and https://.
callbacks
The object that defines the following functions:
  • data(readStream) - called when the output data can be read from readStream
  • error(message, statusCode) - called when an error occurs
  • end() - called when the conversion finishes
The client library provides 2 helper functions that can be used here:
  • saveToFile(filePath[, callback]) - saves the output data to a file
    • filePath - the output file path
    • callback(err, filePath) - called when the conversion finishes
  • sendPdfInHttpResponse(response[, fileName, disposition]) - sends the generated PDF in an HTTP response
    • response - the response object
    • fileName - the desired file name
    • disposition - the response content disposition, can be "attachment" or "inline", the default is "attachment".
function convertUrlToFile(url, filePath, callback)
Convert a web page and write the result to a local file.
url
The address of the web page to convert.
The supported protocols are http:// and https://.
filePath
The output file path.
The string must not be empty.
callback
The callback(error, filePath) function is called when the conversion finishes. The error object is present if an error occurred, filePath is the output file path.
function convertFile(file, callbacks)
Convert a local file.
file
The path to a local file to convert.
The file can be either a single file or an archive (.tar.gz, .tar.bz2, or .zip).
If the HTML document refers to local external assets (images, style sheets, javascript), zip the document together with the assets.
The file must exist and not be empty.
The file name must have a valid extension.
callbacks
The object that defines the following functions:
  • data(readStream) - called when the output data can be read from readStream
  • error(message, statusCode) - called when an error occurs
  • end() - called when the conversion finishes
The client library provides 2 helper functions that can be used here:
  • saveToFile(filePath[, callback]) - saves the output data to a file
    • filePath - the output file path
    • callback(err, filePath) - called when the conversion finishes
  • sendPdfInHttpResponse(response[, fileName, disposition]) - sends the generated PDF in an HTTP response
    • response - the response object
    • fileName - the desired file name
    • disposition - the response content disposition, can be "attachment" or "inline", the default is "attachment".
function convertFileToFile(file, filePath, callback)
Convert a local file and write the result to a local file.
file
The path to a local file to convert.
The file can be either a single file or an archive (.tar.gz, .tar.bz2, or .zip).
If the HTML document refers to local external assets (images, style sheets, javascript), zip the document together with the assets.
The file must exist and not be empty.
The file name must have a valid extension.
filePath
The output file path.
The string must not be empty.
callback
The callback(error, filePath) function is called when the conversion finishes. The error object is present if an error occurred, filePath is the output file path.
function convertString(text, callbacks)
Convert a string.
text
The string content to convert.
The string must not be empty.
callbacks
The object that defines the following functions:
  • data(readStream) - called when the output data can be read from readStream
  • error(message, statusCode) - called when an error occurs
  • end() - called when the conversion finishes
The client library provides 2 helper functions that can be used here:
  • saveToFile(filePath[, callback]) - saves the output data to a file
    • filePath - the output file path
    • callback(err, filePath) - called when the conversion finishes
  • sendPdfInHttpResponse(response[, fileName, disposition]) - sends the generated PDF in an HTTP response
    • response - the response object
    • fileName - the desired file name
    • disposition - the response content disposition, can be "attachment" or "inline", the default is "attachment".
function convertStringToFile(text, filePath, callback)
Convert a string and write the output to a file.
text
The string content to convert.
The string must not be empty.
filePath
The output file path.
The string must not be empty.
callback
The callback(error, filePath) function is called when the conversion finishes. The error object is present if an error occurred, filePath is the output file path.

 

Page Setup

function setPageSize(pageSize)
Set the output page size.
pageSize
Allowed values:
  • A2
  • A3
  • A4
  • A5
  • A6
  • Letter
Default: A4
function setPageWidth(pageWidth)
Set the output page width. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF.
pageWidth
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
Default: 8.27in
Examples:
  • setPageWidth("300mm")
  • setPageWidth("9.5in")
function setPageHeight(pageHeight)
Set the output page height. Use -1 for a single page PDF. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF.
pageHeight
Can be -1 or specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
Default: 11.7in
Examples:
  • setPageHeight("350mm")
  • setPageHeight("15.25in")
  • The height of the page is calculated automatically so that the whole document fits into it.
    setPageHeight("-1")
function setPageDimensions(width, height)
Set the output page dimensions.
width
Set the output page width. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF.
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
Default: 8.27in
height
Set the output page height. Use -1 for a single page PDF. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF.
Can be -1 or specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
Default: 11.7in
Examples:
  • setPageDimensions("300mm", "350mm")
  • setPageDimensions("9.5in", "15.25in")
  • setPageDimensions("372mm", "520pt")
function setOrientation(orientation)
Set the output page orientation.
orientation
Allowed values:
  • landscape
  • portrait
Default: portrait
function setMarginTop(marginTop)
Set the output page top margin.
marginTop
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
Default: 0.4in
Examples:
  • setMarginTop("1in")
  • setMarginTop("2.5cm")
function setMarginRight(marginRight)
Set the output page right margin.
marginRight
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
Default: 0.4in
Examples:
  • setMarginRight("1in")
  • setMarginRight("2.5cm")
function setMarginBottom(marginBottom)
Set the output page bottom margin.
marginBottom
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
Default: 0.4in
Examples:
  • setMarginBottom("1in")
  • setMarginBottom("2.5cm")
function setMarginLeft(marginLeft)
Set the output page left margin.
marginLeft
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
Default: 0.4in
Examples:
  • setMarginLeft("1in")
  • setMarginLeft("2.5cm")
function setNoMargins(noMargins)
Disable page margins.
noMargins
Set to true to disable margins.
Default: false
function setPageMargins(top, right, bottom, left)
Set the output page margins.
top
Set the output page top margin.
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
Default: 0.4in
right
Set the output page right margin.
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
Default: 0.4in
bottom
Set the output page bottom margin.
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
Default: 0.4in
left
Set the output page left margin.
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
Default: 0.4in
function setHeaderUrl(headerUrl)
Load an HTML code from the specified URL and use it as the page header. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows:
  • pdfcrowd-page-count - the total page count of printed pages
  • pdfcrowd-page-number - the current page number
  • pdfcrowd-source-url - the source URL of a converted document
The following attributes can be used:
  • data-pdfcrowd-number-format - specifies the type of the used numerals
    • Arabic numerals are used by default.
    • Roman numerals can be generated by the roman and roman-lowercase values
      • Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span>
  • data-pdfcrowd-placement - specifies where to place the source URL, allowed values:
    • The URL is inserted to the content
      • Example: <span class='pdfcrowd-source-url'></span>
        will produce <span>http://example.com</span>
    • href - the URL is set to the href attribute
      • Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a>
        will produce <a href='http://example.com'>Link to source</a>
    • href-and-content - the URL is set to the href attribute and to the content
      • Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a>
        will produce <a href='http://example.com'>http://example.com</a>
headerUrl
The supported protocols are http:// and https://.
Examples:
  • setHeaderUrl("http://myserver.com/header.html")
function setHeaderHtml(headerHtml)
Use the specified HTML code as the page header. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows:
  • pdfcrowd-page-count - the total page count of printed pages
  • pdfcrowd-page-number - the current page number
  • pdfcrowd-source-url - the source URL of a converted document
The following attributes can be used:
  • data-pdfcrowd-number-format - specifies the type of the used numerals
    • Arabic numerals are used by default.
    • Roman numerals can be generated by the roman and roman-lowercase values
      • Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span>
  • data-pdfcrowd-placement - specifies where to place the source URL, allowed values:
    • The URL is inserted to the content
      • Example: <span class='pdfcrowd-source-url'></span>
        will produce <span>http://example.com</span>
    • href - the URL is set to the href attribute
      • Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a>
        will produce <a href='http://example.com'>Link to source</a>
    • href-and-content - the URL is set to the href attribute and to the content
      • Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a>
        will produce <a href='http://example.com'>http://example.com</a>
headerHtml
The string must not be empty.
Examples:
  • It displays the page number and the total page count.
    setHeaderHtml("Page <span class='pdfcrowd-page-number'></span> of <span class='pdfcrowd-page-count'></span> pages")
function setHeaderHeight(headerHeight)
Set the header height.
headerHeight
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
Default: 0.5in
Examples:
  • setHeaderHeight("30mm")
  • setHeaderHeight("1in")
Load an HTML code from the specified URL and use it as the page footer. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows:
  • pdfcrowd-page-count - the total page count of printed pages
  • pdfcrowd-page-number - the current page number
  • pdfcrowd-source-url - the source URL of a converted document
The following attributes can be used:
  • data-pdfcrowd-number-format - specifies the type of the used numerals
    • Arabic numerals are used by default.
    • Roman numerals can be generated by the roman and roman-lowercase values
      • Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span>
  • data-pdfcrowd-placement - specifies where to place the source URL, allowed values:
    • The URL is inserted to the content
      • Example: <span class='pdfcrowd-source-url'></span>
        will produce <span>http://example.com</span>
    • href - the URL is set to the href attribute
      • Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a>
        will produce <a href='http://example.com'>Link to source</a>
    • href-and-content - the URL is set to the href attribute and to the content
      • Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a>
        will produce <a href='http://example.com'>http://example.com</a>
Examples:
  • setFooterUrl("http://myserver.com/header.html")
Use the specified HTML as the page footer. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows:
  • pdfcrowd-page-count - the total page count of printed pages
  • pdfcrowd-page-number - the current page number
  • pdfcrowd-source-url - the source URL of a converted document
The following attributes can be used:
  • data-pdfcrowd-number-format - specifies the type of the used numerals
    • Arabic numerals are used by default.
    • Roman numerals can be generated by the roman and roman-lowercase values
      • Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span>
  • data-pdfcrowd-placement - specifies where to place the source URL, allowed values:
    • The URL is inserted to the content
      • Example: <span class='pdfcrowd-source-url'></span>
        will produce <span>http://example.com</span>
    • href - the URL is set to the href attribute
      • Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a>
        will produce <a href='http://example.com'>Link to source</a>
    • href-and-content - the URL is set to the href attribute and to the content
      • Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a>
        will produce <a href='http://example.com'>http://example.com</a>
Examples:
  • It displays the page number and the total page count.
    setFooterHtml("Page <span class='pdfcrowd-page-number'></span> of <span class='pdfcrowd-page-count'></span> pages")
Set the footer height.
Examples:
  • setFooterHeight("30mm")
  • setFooterHeight("1in")
function setPrintPageRange(pages)
Set the page range to print.
pages
A comma separated list of page numbers or ranges.
Examples:
  • Just the second page is printed.
    setPrintPageRange("2")
  • The first and the third page are printed.
    setPrintPageRange("1,3")
  • Everything except the first page is printed.
    setPrintPageRange("2-")
  • Just first 3 pages are printed.
    setPrintPageRange("-3")
  • Pages 3, 6, 7, 8 and 9 are printed.
    setPrintPageRange("3,6-9")
function setExcludeHeaderOnPages(pages)
The page header is not printed on the specified pages.
pages
List of physical page numbers. Negative numbers count backwards from the last page: -1 is the last page, -2 is the last but one page, and so on.
A comma separated list of page numbers.
Examples:
  • The header is not printed on the second page.
    setExcludeHeaderOnPages("2")
  • The header is not printed on the first and the last page.
    setExcludeHeaderOnPages("1,-1")
The page footer is not printed on the specified pages.
Examples:
  • The footer is not printed on the second page.
    setExcludeFooterOnPages("2")
  • The footer is not printed on the first and the last page.
    setExcludeFooterOnPages("1,-1")
function setPageNumberingOffset(offset)
Set an offset between physical and logical page numbers.
offset
Integer specifying page offset.
Default: 0
Examples:
  • The page numbering will start with 0. Set exclude_header_on_pages to "1" and the page numbering will start on the second page with 1.
    setPageNumberingOffset(1)
  • The page numbering will start with 11 on the first page. It can be useful for joining documents.
    setPageNumberingOffset(-10)
function setContentAreaX(contentAreaX)
Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area.
contentAreaX
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
Default: 0in
Examples:
  • setContentAreaX("-1in")
  • setContentAreaX("2.5cm")
function setContentAreaY(contentAreaY)
Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area.
contentAreaY
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
Default: 0in
Examples:
  • setContentAreaY("-1in")
  • setContentAreaY("2.5cm")
function setContentAreaWidth(contentAreaWidth)
Set the width of the content area. It should be at least 1 inch.
contentAreaWidth
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
Default: The width of the print area.
Examples:
  • setContentAreaWidth("8in")
  • setContentAreaWidth("25cm")
function setContentAreaHeight(contentAreaHeight)
Set the height of the content area. It should be at least 1 inch.
contentAreaHeight
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
Default: The height of the print area.
Examples:
  • setContentAreaHeight("8in")
  • setContentAreaHeight("25cm")
function setContentArea(x, y, width, height)
Set the content area position and size. The content area enables to specify a web page area to be converted.
x
Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area.
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
Default: 0in
y
Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area.
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
Default: 0in
width
Set the width of the content area. It should be at least 1 inch.
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
Default: The width of the print area.
height
Set the height of the content area. It should be at least 1 inch.
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
Default: The height of the print area.

 

Watermark & Background

function setPageWatermark(pageWatermark)
Apply the first page of the watermark PDF to every page of the output PDF.
pageWatermark
The file path to a local watermark PDF file.
The file must exist and not be empty.
function setPageWatermarkUrl(pageWatermarkUrl)
Load a watermark PDF from the specified URL and apply the first page of the watermark PDF to every page of the output PDF.
pageWatermarkUrl
The supported protocols are http:// and https://.
Examples:
  • setPageWatermarkUrl("http://myserver.com/watermark.pdf")
function setMultipageWatermark(multipageWatermark)
Apply each page of the specified watermark PDF to the corresponding page of the output PDF.
multipageWatermark
The file path to a local watermark PDF file.
The file must exist and not be empty.
function setMultipageWatermarkUrl(multipageWatermarkUrl)
Load a watermark PDF from the specified URL and apply each page of the specified watermark PDF to the corresponding page of the output PDF.
multipageWatermarkUrl
The supported protocols are http:// and https://.
Examples:
  • setMultipageWatermarkUrl("http://myserver.com/watermark.pdf")
function setPageBackground(pageBackground)
Apply the first page of the specified PDF to the background of every page of the output PDF.
pageBackground
The file path to a local background PDF file.
The file must exist and not be empty.
function setPageBackgroundUrl(pageBackgroundUrl)
Load a background PDF from the specified URL and apply the first page of the background PDF to every page of the output PDF.
pageBackgroundUrl
The supported protocols are http:// and https://.
Examples:
  • setPageBackgroundUrl("http://myserver.com/background.pdf")
function setMultipageBackground(multipageBackground)
Apply each page of the specified PDF to the background of the corresponding page of the output PDF.
multipageBackground
The file path to a local background PDF file.
The file must exist and not be empty.
function setMultipageBackgroundUrl(multipageBackgroundUrl)
Load a background PDF from the specified URL and apply each page of the specified background PDF to the corresponding page of the output PDF.
multipageBackgroundUrl
The supported protocols are http:// and https://.
Examples:
  • setMultipageBackgroundUrl("http://myserver.com/background.pdf")
function setPageBackgroundColor(pageBackgroundColor)
The page background color in RGB or RGBA hexadecimal format. The color fills the entire page regardless of the margins.
pageBackgroundColor
The value must be in RRGGBB or RRGGBBAA hexadecimal format.
Examples:
  • red color
    setPageBackgroundColor("FF0000")
  • green color
    setPageBackgroundColor("00ff00")
  • green color with 50% opacity
    setPageBackgroundColor("00ff0080")

 

General Options

function setNoBackground(noBackground)
Do not print the background graphics.
noBackground
Set to true to disable the background graphics.
Default: false
function setDisableJavascript(disableJavascript)
Do not execute JavaScript.
disableJavascript
Set to true to disable JavaScript in web pages.
Default: false
function setDisableImageLoading(disableImageLoading)
Do not load images.
disableImageLoading
Set to true to disable loading of images.
Default: false
function setDisableRemoteFonts(disableRemoteFonts)
Disable loading fonts from remote sources.
disableRemoteFonts
Set to true disable loading remote fonts.
Default: false
function setBlockAds(blockAds)
Try to block ads. Enabling this option can produce smaller output and speed up the conversion.
blockAds
Set to true to block ads in web pages.
Default: false
function setDefaultEncoding(defaultEncoding)
Set the default HTML content text encoding.
defaultEncoding
The text encoding of the HTML content.
Default: auto detect
function setHttpAuth(userName, password)
Set credentials to access HTTP base authentication protected websites.
userName
Set the HTTP authentication user name.
password
Set the HTTP authentication password.
function setUsePrintMedia(usePrintMedia)
Use the print version of the page if available (@media print).
usePrintMedia
Set to true to use the print version of the page.
Default: false
function setNoXpdfcrowdHeader(noXpdfcrowdHeader)
Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
noXpdfcrowdHeader
Set to true to disable sending X-Pdfcrowd HTTP header.
Default: false
function setCookies(cookies)
Set cookies that are sent in Pdfcrowd HTTP requests.
cookies
The cookie string.
Examples:
  • setCookies("session=6d7184b3bf35;token=2710")
function setVerifySslCertificates(verifySslCertificates)
Do not allow insecure HTTPS connections.
verifySslCertificates
Set to true to enable SSL certificate verification.
Default: false
function setFailOnMainUrlError(failOnError)
Abort the conversion if the main URL HTTP status code is greater than or equal to 400.
failOnError
Set to true to abort the conversion.
Default: false
function setFailOnAnyUrlError(failOnError)
Abort the conversion if any of the sub-request HTTP status code is greater than or equal to 400 or if some sub-requests are still pending. See details in a debug log.
failOnError
Set to true to abort the conversion.
Default: false
function setCustomJavascript(customJavascript)
Run a custom JavaScript after the document is loaded and ready to print. The script is intended for post-load DOM manipulation (add/remove elements, update CSS, ...). In addition to the standard browser APIs, the custom JavaScript code can use helper functions from our JavaScript library.
customJavascript
A string containing a JavaScript code.
The string must not be empty.
function setOnLoadJavascript(onLoadJavascript)
Run a custom JavaScript right after the document is loaded. The script is intended for early DOM manipulation (add/remove elements, update CSS, ...). In addition to the standard browser APIs, the custom JavaScript code can use helper functions from our JavaScript library.
onLoadJavascript
A string containing a JavaScript code.
The string must not be empty.
function setCustomHttpHeader(customHttpHeader)
Set a custom HTTP header that is sent in Pdfcrowd HTTP requests.
customHttpHeader
A string containing the header name and value separated by a colon.
Examples:
  • setCustomHttpHeader("X-My-Client-ID:k2017-12345")
function setJavascriptDelay(javascriptDelay)
Wait the specified number of milliseconds to finish all JavaScript after the document is loaded. The maximum value is determined by your API license.
javascriptDelay
The number of milliseconds to wait.
Must be a positive integer number or 0.
Default: 200
function setElementToConvert(selectors)
Convert only the specified element from the main document and its children. The element is specified by one or more CSS selectors. If the element is not found, the conversion fails. If multiple elements are found, the first one is used.
selectors
One or more CSS selectors separated by commas.
The string must not be empty.
Examples:
  • The first element with the id main-content is converted.
    setElementToConvert("#main-content")
  • The first element with the class name main-content is converted.
    setElementToConvert(".main-content")
  • The first element with the tag name table is converted.
    setElementToConvert("table")
  • The first element with the tag name table or with the id main-content is converted.
    setElementToConvert("table, #main-content")
  • The first element <p class="article"> within <div class="user-panel main"> is converted.
    setElementToConvert("div.user-panel.main p.article")
function setElementToConvertMode(mode)
Specify the DOM handling when only a part of the document is converted.
mode
Allowed values:
  • cut-out
    The element and its children are cut out of the document.
  • remove-siblings
    All element's siblings are removed.
  • hide-siblings
    All element's sibilings are hidden.
Default: cut-out
function setWaitForElement(selectors)
Wait for the specified element in a source document. The element is specified by one or more CSS selectors. The element is searched for in the main document and all iframes. If the element is not found, the conversion fails. Your API license defines the maximum wait time by "Max Delay" parameter.
selectors
One or more CSS selectors separated by commas.
The string must not be empty.
Examples:
  • Wait until an element with the id main-content is found.
    setWaitForElement("#main-content")
  • Wait until an element with the class name main-content is found.
    setWaitForElement(".main-content")
  • Wait until an element with the tag name table is found.
    setWaitForElement("table")
  • Wait until an element with the tag name table or with the id main-content is found.
    setWaitForElement("table, #main-content")
  • Wait until <p class="article"> is found within <div class="user-panel main">.
    setWaitForElement("div.user-panel.main p.article")

 

function setViewportWidth(viewportWidth)
Set the viewport width in pixels. The viewport is the user's visible area of the page.
viewportWidth
The value must be in the range 96-65000.
Default: 1024
function setViewportHeight(viewportHeight)
Set the viewport height in pixels. The viewport is the user's visible area of the page.
viewportHeight
Must be a positive integer number.
Default: 768
function setViewport(width, height)
Set the viewport size. The viewport is the user's visible area of the page.
width
Set the viewport width in pixels. The viewport is the user's visible area of the page.
The value must be in the range 96-65000.
Default: 1024
height
Set the viewport height in pixels. The viewport is the user's visible area of the page.
Must be a positive integer number.
Default: 768
function setRenderingMode(renderingMode)
Set the rendering mode.
renderingMode
The rendering mode.
Allowed values:
  • default
    This mode is based on the standard browser print functionality.
  • viewport
    The viewport width affects the @media min-width and max-width CSS properties. This mode can be used to choose a particular version (mobile, desktop, ..) of a responsive page.
Default: default
function setSmartScalingMode(smartScalingMode)
Specifies the scaling mode used for fitting the HTML contents to the print area.
smartScalingMode
The smart scaling mode.
Allowed values:
  • default
    This mode is based on the standard browser print functionality.
  • disabled
    No smart scaling is performed.
  • viewport-fit
    The viewport width fits the print area width.
  • content-fit
    The HTML contents width fits the print area width.
  • single-page-fit
    The whole HTML contents fits the print area of a single page.
Default: default
function setScaleFactor(scaleFactor)
Set the scaling factor (zoom) for the main page area.
scaleFactor
The percentage value.
The value must be in the range 10-500.
Default: 100
Set the scaling factor (zoom) for the header and footer.
function setDisableSmartShrinking(disableSmartShrinking)
Disable the intelligent shrinking strategy that tries to optimally fit the HTML contents to a PDF page.
disableSmartShrinking
Set to true to disable the intelligent shrinking strategy.
Default: false
function setJpegQuality(jpegQuality)
Set the quality of embedded JPEG images. A lower quality results in a smaller PDF file but can lead to compression artifacts.
jpegQuality
The percentage value.
The value must be in the range 1-100.
Default: 100
function setConvertImagesToJpeg(convertImagesToJpeg)
Specify which image types will be converted to JPEG. Converting lossless compression image formats (PNG, GIF, ...) to JPEG may result in a smaller PDF file.
convertImagesToJpeg
The image category.
Allowed values:
  • none
    No image conversion is done.
  • opaque
    Only opaque images are converted to JPEG images.
  • all
    All images are converted to JPEG images. The JPEG format does not support transparency so the transparent color is replaced by a PDF page background color.
Default: none
function setImageDpi(imageDpi)
Set the DPI of images in PDF. A lower DPI may result in a smaller PDF file. If the specified DPI is higher than the actual image DPI, the original image DPI is retained (no upscaling is performed). Use 0 to leave the images unaltered.
imageDpi
The DPI value.
Must be a positive integer number or 0.
Default: 0
Examples:
  • No change of the source image is done.
    setImageDpi(0)
  • Screen-only view lower DPI.
    setImageDpi(72)
  • Screen-only view recommended DPI.
    setImageDpi(96)
  • Ebook typical DPI.
    setImageDpi(150)
  • Printer standard DPI.
    setImageDpi(300)

 

PDF Format

Miscellaneous values for PDF output.

function setLinearize(linearize)
Create linearized PDF. This is also known as Fast Web View.
linearize
Set to true to create linearized PDF.
Default: false
function setEncrypt(encrypt)
Encrypt the PDF. This prevents search engines from indexing the contents.
encrypt
Set to true to enable PDF encryption.
Default: false
function setUserPassword(userPassword)
Protect the PDF with a user password. When a PDF has a user password, it must be supplied in order to view the document and to perform operations allowed by the access permissions.
userPassword
The user password.
function setOwnerPassword(ownerPassword)
Protect the PDF with an owner password. Supplying an owner password grants unlimited access to the PDF including changing the passwords and access permissions.
ownerPassword
The owner password.
function setNoPrint(noPrint)
Disallow printing of the output PDF.
noPrint
Set to true to set the no-print flag in the output PDF.
Default: false
function setNoModify(noModify)
Disallow modification of the output PDF.
noModify
Set to true to set the read-only only flag in the output PDF.
Default: false
function setNoCopy(noCopy)
Disallow text and graphics extraction from the output PDF.
noCopy
Set to true to set the no-copy flag in the output PDF.
Default: false
function setTitle(title)
Set the title of the PDF.
title
The title.
function setSubject(subject)
Set the subject of the PDF.
subject
The subject.
function setAuthor(author)
Set the author of the PDF.
author
The author.
function setKeywords(keywords)
Associate keywords with the document.
keywords
The string with the keywords.

 

Viewer Preferences

These preferences specify how a PDF viewer should present the document. The preferences may be ignored by some PDF viewers.

function setPageLayout(pageLayout)
Specify the page layout to be used when the document is opened.
pageLayout
Allowed values:
  • single-page
    Display one page at a time.
  • one-column
    Display the pages in one column.
  • two-column-left
    Display the pages in two columns, with odd-numbered pages on the left.
  • two-column-right
    Display the pages in two columns, with odd-numbered pages on the right.
function setPageMode(pageMode)
Specify how the document should be displayed when opened.
pageMode
Allowed values:
  • full-screen
    Full-screen mode.
  • thumbnails
    Thumbnail images are visible.
  • outlines
    Document outline is visible.
function setInitialZoomType(initialZoomType)
Specify how the page should be displayed when opened.
initialZoomType
Allowed values:
  • fit-width
    The page content is magnified just enough to fit the entire width of the page within the window.
  • fit-height
    The page content is magnified just enough to fit the entire height of the page within the window.
  • fit-page
    The page content is magnified just enough to fit the entire page within the window both horizontally and vertically. If the required horizontal and vertical magnification factors are different, use the smaller of the two, centering the page within the window in the other dimension.
function setInitialPage(initialPage)
Display the specified page when the document is opened.
initialPage
Must be a positive integer number.
function setInitialZoom(initialZoom)
Specify the initial page zoom in percents when the document is opened.
initialZoom
Must be a positive integer number.
function setHideToolbar(hideToolbar)
Specify whether to hide the viewer application's tool bars when the document is active.
hideToolbar
Set to true to hide tool bars.
Default: false
function setHideMenubar(hideMenubar)
Specify whether to hide the viewer application's menu bar when the document is active.
hideMenubar
Set to true to hide the menu bar.
Default: false
function setHideWindowUi(hideWindowUi)
Specify whether to hide user interface elements in the document's window (such as scroll bars and navigation controls), leaving only the document's contents displayed.
hideWindowUi
Set to true to hide ui elements.
Default: false
function setFitWindow(fitWindow)
Specify whether to resize the document's window to fit the size of the first displayed page.
fitWindow
Set to true to resize the window.
Default: false
function setCenterWindow(centerWindow)
Specify whether to position the document's window in the center of the screen.
centerWindow
Set to true to center the window.
Default: false
function setDisplayTitle(displayTitle)
Specify whether the window's title bar should display the document title. If false , the title bar should instead display the name of the PDF file containing the document.
displayTitle
Set to true to display the title.
Default: false
function setRightToLeft(rightToLeft)
Set the predominant reading order for text to right-to-left. This option has no direct effect on the document's contents or page numbering but can be used to determine the relative positioning of pages when displayed side by side or printed n-up
rightToLeft
Set to true to set right-to-left reading order.
Default: false

 

Miscellaneous

function setDebugLog(debugLog)
Turn on the debug logging. Details about the conversion are stored in the debug log. The URL of the log can be obtained from the getDebugLogUrl method or available in conversion statistics.
debugLog
Set to true to enable the debug logging.
Default: false
function getDebugLogUrl()
Get the URL of the debug log for the last conversion.
Returns
  • string - The link to the debug log.
function getRemainingCreditCount()
Get the number of conversion credits available in your account.
This method can only be called after a call to one of the convertXYZ methods.
The returned value can differ from the actual count if you run parallel conversions.
The special value 999999 is returned if the information is not available.
Returns
  • int - The number of credits.
function getConsumedCreditCount()
Get the number of credits consumed by the last conversion.
Returns
  • int - The number of credits.
function getJobId()
Get the job id.
Returns
  • string - The unique job identifier.
function getPageCount()
Get the total number of pages in the output document.
Returns
  • int - The page count.
function getOutputSize()
Get the size of the output in bytes.
Returns
  • int - The count of bytes.
function setTag(tag)
Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
tag
A string with the custom tag.
function setHttpProxy(httpProxy)
A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTP scheme. It can help to circumvent regional restrictions or provide limited access to your intranet.
httpProxy
The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
Examples:
  • setHttpProxy("myproxy.com:8080")
  • setHttpProxy("113.25.84.10:33333")
function setHttpsProxy(httpsProxy)
A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTPS scheme. It can help to circumvent regional restrictions or provide limited access to your intranet.
httpsProxy
The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
Examples:
  • setHttpsProxy("myproxy.com:443")
  • setHttpsProxy("113.25.84.10:44333")
function setClientCertificate(clientCertificate)
A client certificate to authenticate Pdfcrowd converter on your web server. The certificate is used for two-way SSL/TLS authentication and adds extra security.
clientCertificate
The file must be in PKCS12 format.
The file must exist and not be empty.
function setClientCertificatePassword(clientCertificatePassword)
A password for PKCS12 file with a client certificate if it is needed.
clientCertificatePassword

 

API Client Options

function setUseHttp(useHttp)
Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
useHttp
Set to true to use HTTP.
Default: false
function setUserAgent(userAgent)
Set a custom user agent HTTP header. It can be usefull if you are behind some proxy or firewall.
userAgent
The user agent string.
Default: pdfcrowd_nodejs_client/4.11.0 (http://pdfcrowd.com)
function setProxy(host, port, userName, password)
Specifies an HTTP proxy that the API client library will use to connect to the internet.
host
The proxy hostname.
port
The proxy port.
userName
The username.
password
The password.
function setRetryCount(retryCount)
Specifies the number of retries when the 502 HTTP status code is received. The 502 status code indicates a temporary network issue. This feature can be disabled by setting to 0.
retryCount
Number of retries wanted.
Default: 1