Convert HTML to PDF
without effort

Our API makes PDFs from webpages or HTML. Fast, easy and reliable!
Try it with any URL below or scroll down to the code examples.

Create perfect PDFs from webpages in your application

How to use our HTML2PDF API

Below you'll find basic examples for all major programming languages. With just a few lines of code you can convert any URL or HTML to PDF. You can find all options and examples in our API documentation and the description of the click to PDF links.

// the following code converts the URL to PDF in PHP

$url = urlencode("");
$license = "yourlicensekey";
// now we call the HTML2PDF API
$pdf = file_get_contents("{$license}&url={$url}";

// the PDF is stored in the parameter $pdf now

Note - we also have a HTML2PDF PHP library available!

// the following code converts the URL to PDF in C#/ .NET

string license = "yourlicensekey";
string url = System.Net.WebUtility.UrlEncode("");

using (var client = new WebClient())
    client.QueryString.Add("license", license);
    client.QueryString.Add("url", url);
    client.DownloadFile("", @"c:\temp\mypdf.pdf");

// the following code converts the URL to PDF in Java

String license = "yourlicensekey";
String url = URLEncoder.encode("",java.nio.charset.StandardCharsets.UTF_8.toString() );
File outs = new File("C:\\temp\mypdf.pdf");

URL u = new URL("" + license + "&url=" + url);
URLConnection uc = u.openConnection();
BufferedInputStream is = new BufferedInputStream(uc.getInputStream());
BufferedOutputStream bout = new BufferedOutputStream(new FileOutputStream(outs));

byte[] b = new byte[8 * 1024];
int read = 0;
while ((read = > -1) {
	bout.write(b, 0, read);

// the following code converts the URL to PDF in Python

import urllib2

data = {
   'license': 'yourlicensekey',
   'url': ''
requesturl = '{license}&url={url}'.format(**data)
result = urllib2.urlopen(requesturl)
localFile = open('mypdf.pdf', 'w')

# the following code converts the URL to PDF in Ruby

require 'net/http'
license = 'yourlicensekey'
url = ''

uri = URI("{license}&url=#{url}")
Net::HTTP.start(, uri.port) do |http|
  request = uri.request_uri

  http.request request do |response|
    open 'mypdf.pdf', 'w' do |io|
      response.read_body do |chunk|
        io.write chunk

# the following code converts the URL to PDF in Perl

use File::Fetch;
use URI::Escape;

my $license = "yourlicensekey";
my $url = uri_escape("");

my $ff = File::Fetch->new(uri => "$license&url=$url");
my $where = $ff->fetch( to => '/tmp');

# The following cURL command converts the URL to a PDF with the name result.pdf

curl 	-d "license=yourlicensekey" \
	--data-urlencode "url=" \
	-o result.pdf \
	-H "Content-Type: application/x-www-form-urlencoded" \

# If you want to use HTML instead, then you can use the following cURL command to convert a file html.html with HTML to PDF

curl 	-d "license=yourlicensekey" \
	--data-urlencode html@html.html \
	-o result.pdf \
	-H "Content-Type: application/x-www-form-urlencoded" \

# The following Wget command converts the URL to a PDF with the name result.pdf

wget -O result.pdf --post-data="license=yourlicensekey&url="

<!-- If you want to add a Click to PDF link to your pages, then just add the following link -->

<a href="javascript:location.href=''+escape(location.href)">Click to PDF</a>

<!-- We also have a custom function that uses JavaScript or jQuery to send the contents of a webpage to us for conversion -->

<a href="#;" onclick="HTML2PDF()">Click to PDF</a>

function HTML2PDF () {
	// Replace this with your HTML2PDF license
	var license = 'yourlicensekey';
	// First we take the HTML of the page
	var html = '', node = document.firstChild;
	while (node) {
		switch (node.nodeType) {
			case Node.ELEMENT_NODE:
				html += node.outerHTML;
			case Node.TEXT_NODE:
				html += node.nodeValue;
				html += '<![CDATA[' + node.nodeValue + ']]>';
			case Node.COMMENT_NODE:
				html += '<!--' + node.nodeValue + '-->';
				// (X)HTML documents are identified by public identifiers
				html += "<!DOCTYPE " + + (node.publicId ? ' PUBLIC "' + node.publicId + '"' : '') + (!node.publicId && node.systemId ? ' SYSTEM' : '') + (node.systemId ? ' "' + node.systemId + '"' : '') + '>\n';
		node = node.nextSibling;

	// We pass the html and our license 
	// You don't need to pass any other parameters if your defaults in our members area are already good
	var data = { html: html, license:license};
	var serialized = Object.keys(data).map(function(k) { 
		return encodeURIComponent(k) + '=' + encodeURIComponent(data[k])
	// You can insert an "in progress" message here
	// We now prepare the API call
	xhttp = new XMLHttpRequest();
	xhttp.onreadystatechange = function() {
		var a;
		if (xhttp.readyState === 4 && xhttp.status === 200) {
			// The PDF is now generated
			// You can remove the "in progress" message here
			// Now we show the PDF to the user
			var filename = "example.pdf";
			if (window.navigator && window.navigator.msSaveOrOpenBlob) { 
				window.navigator.msSaveOrOpenBlob(xhttp.response, filename);
			} else { 
				a = document.createElement('a');
				a.href = window.URL.createObjectURL(xhttp.response); = filename; = 'none';
	// This is the actual call to our API"POST", "", true);
	xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	xhttp.responseType = 'blob';

What will you get?

The easiest service to use and the privacy of your data guaranteed!

Easy Integration

You can set all your conversion options in a WYSIWIG members area and use our API with just a few lines of code.

Many Layout Options

Custom page sizes, header, footer and many more easy to configure settings at your disposal.

High Quality Output

PDFs that look EXACTLY like what you see on the screen and that can be used in professional settings.

Great Support

We love what we do and have been doing it since 2008. We know what you need and are happy to help!

Long History

We have been around for a long time and thousands of customers trust and have trusted us. You can too!


99.9% Uptime and the latest technology in use. You can let us worry about delivering and maintaining!

What do our customers say?

We are running HTML2PDF since 2008 and hundreds of companies have trusted our service in the past.

" We're running this without fail for years now. Excellent! "

- Julien LaCoste

" Thanks for all your help. I appreciate how kind your support is!"

- SamHomeGauge

" Thanks for the great solution and the speedy support. You're a lifesaver!"

- MinBillTrust

Get a Free Trial

If you want to try our API first, then please feel free to get a free trial!