Convert HTML code to PDF document in your app.

Want to generate PDF invoices for your client? Simply create a HTML/CSS version of the invoice, and use the PDFace HTML to PDF API to convert this HTML document into a PDF file.

Getting Started API is very easy to use. All you need to do is "POST" request parameters to a URL and get back PDF in response. See below for more details.

API End Point

"POST" your requests to the below URL. Make sure to always use HTTPS. Non-SSL requests will be rejected.

Authenticate API Calls

Each API call needs to include a "hash" POST parameter. To generate a hash, you will need:

  1. API Key
  2. Hash Key
$api_key = "YOUR_API_KEY";
$hash_key = "YOUR_API_HASH_KEY";
$hash = sha1($api_key . $hash_key);

API Credentials

Follow the below steps to generate new API key/secret:

  1. Login to your account and navigate to "API Keys" tab.
  2. Click on "Generate new API Key" button.
  3. Input name and click on "Add API Key" button.


$api_key = "YOUR_API_KEY";
$hash_key = "YOUR_API_HASH_KEY";
$hash = sha1($api_key . $hash_key);

$params = [
	"key" => $api_key,
	"hash" => $hash,
	"type" => "html",
	"data" => "<h1>Hello World!</h1>",
	"title" => " HTML to PDF API Example",
	"orientation" => "Landscape"

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "");
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$pdf_response = curl_exec($ch);

$response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error_str = curl_error($ch);


if ($response_code == 200) {
	//Save PDF response to a file
	file_put_contents("hello_world.pdf", $pdf_response);
}else {
	echo "Error: $pdf_response";

Request Parameters

List of all request parameters available to the API. You can use these request parameters to control the PDF document generated by the API.

Parameter Type Mandatory Description
key String Yes Your API Key. Login to your account to manage and generate new API keys.
hash String Yes Security hash to authenticate API calls. See "Authenticate API Calls" below.
type String Yes For now, set this to "html".
data String Yes The HTML code that you want to convert to PDF.
<h1>Hello World</h1>
<p><strong>Welcome</strong> to</p>
orientation String No Page orientation. Set to Landscape or Portrait (default Portrait).
page-size String No Page size. Example: A4, A5, B0, B1, Executive, Letter etc.
title String No Title of the generated PDF file.
image-quality Integer No Image quality to use when JPEG compressing images (default 94).
margin-top Integer No Page top margin. Examples: 10mm, 1cm, 20pixel.
margin-bottom Integer No Page bottom margin. Examples: 10mm, 1cm, 20pixel.
margin-left Integer No Page left margin. Examples: 10mm, 1cm, 20pixel.
margin-right Integer No Page right margin. Examples: 10mm, 1cm, 20pixel.
no-outline Integer (0/1) No By default the API will put an outline into the PDF file. Set this to 1 to prevent this.
grayscale Integer (0/1) No Set to 1 to generate PDF in grayscale.
disable-external-links Integer (0/1) No Set to 1 to stop API from rendering links to remote webpages.
no-images Integer (0/1) No Set to 1 to exclude images from the generated PDF file.
print-media-type Integer (0/1) No Set to 1 use print media-type instead of screen.