HTML to PDF Conversion

FREE
By restpack
Updated 4 months ago
Tools
6.8/10
Popularity Score
761ms
Latency
4%
Success Rate

HTML to PDF Conversion API Documentation

The best HTML to PDF API in the market. Test without registering and providing access token. Restpack HTML to PDF API is an easy to use RESTful web service that can capture live web pages and deliver the structured view as a PDF document. The service sits on a fully functional browser rendering engine with rich html / css / js capabilities.

View API Details
GETconvert
POSTconvertWithPost
GETconvert

Convert PDF from Raw HTML or URL

Authorization:

There is no requirement to obtain a token for testing purposes, responses will be watermarked in that case. To remove the watermark, an access token should be obtained from https://restpack.io by creating a free account. Token is accepted in x-access-token header or access_token querystring parameter.

Header Parameters
X-RapidAPI-HostSTRING
REQUIRED
X-RapidAPI-KeySTRING
REQUIRED
Optional Parameters
htmlSTRING
OPTIONALRaw HTML string of a page that you want to capture. Example: <p>Test</p>
jsonBOOLEAN
OPTIONALReturn a JSON response with the resulting image's URL instead of the image itself. Default: false
pdf_pageSTRING
OPTIONALCustom page size for created document Default: Full Pattern: A3 | A4 | A5 | Legal | Letter | Tabloid | Full
pdf_marginsSTRING
OPTIONAL0 for default margins, 1 for no margins, 2 for minimal margins Default: 0 Pattern: 0 | 1 | 2
cssSTRING
OPTIONALAdditional CSS string to be injected into the page before render.
jsSTRING
OPTIONALAdditional JS string to be injected into the page before render.
prescrollBOOLEAN
OPTIONALForce scrolling the webpage before capture. Might help with dynamic loading assets.
delayNUMBER
OPTIONALTime in milliseconds to delay capture after page load. Default: 2000 Max: 10000
ttlNUMBER
OPTIONALTime in milliseconds for the resulting image to be cached for further requests. Default: 1 day Max: 1 week
freshBOOLEAN
OPTIONALForce rendering a new screenshot disregarding the cache status. Default: false
user_agentSTRING
OPTIONALCustom user-agent header string for the web request. Default: Chrome Compatible User Agent
accept_languageSTRING
OPTIONALCustom accept-language header string for the web request.
headersSTRING
OPTIONALAdditional headers seperated with newline Example: X-Test: header\nAccept-Type: html
base64BOOLEAN
OPTIONALSerialize response file to base64
urlSTRING
OPTIONALThe URL of web page, including the protocol that you want to capture.
access_tokenSTRING
OPTIONALYou can provide your token via querystring instead of header.
Code Snippet
unirest.get("https://restpack-restpack-html-to-pdf-v2.p.rapidapi.com/convert?url=http%3A%2F%2Fchartjs.org%2F")
.header("X-RapidAPI-Host", "restpack-restpack-html-to-pdf-v2.p.rapidapi.com")
.header("X-RapidAPI-Key", "SIGN-UP-FOR-KEY")
.end(function (result) {
  console.log(result.status, result.headers, result.body);
});
Sample Response
General
Request URL: https://restpack-restpack-html-to-pdf-v2.p.rapidapi.com/convert
Request Method: GET
Response Headers
Response Body

Install SDK for NodeJS

Installing

To utilize unirest for node.js install the the npm module:

$ npm install unirest

After installing the npm package you can now start simplifying requests like so:

var unirest = require('unirest');

Creating Request

unirest.get("https://restpack-restpack-html-to-pdf-v2.p.rapidapi.com/convert?url=http%3A%2F%2Fchartjs.org%2F")
.header("X-RapidAPI-Host", "restpack-restpack-html-to-pdf-v2.p.rapidapi.com")
.header("X-RapidAPI-Key", "SIGN-UP-FOR-KEY")
.end(function (result) {
  console.log(result.status, result.headers, result.body);
});
OAuth2 Authentication
Client ID
Client Secret
OAuth2 Authentication