http Interface

The http WebService of HTML2PDF may be used with the GET or POST method at this address:

These parameters will be consumed:


The URI string of the website that should be converted to PDF. This string may be up to 4096 characters long. The address has to start with http or https – other protocols are not supported currently.


The license key as string, if available. Otherwise simply skip this parameter.


If you have a license key, you can define an individual heading text here that is displayed on every page of the PDF. Without a license key a default text with a link to the WebService will be shown there. If you have no license key, you should skip this parameter.


Set this to „Portrait“ or „Landscape“ to define the page orientation.


Set this to „1“ or „0“ to en- or disable processing background colors and images.


Set this to „1“ or „0“ to en- or disable processing print media CSS.


If this parameter contains the value „1“, the WebService will return the PDF data without base64 encoding in binary format. Then the browser may try to display the PDF with help of ActiveX components inline of the browser window. If you want to get the base64 encoded PDF data, simply skip this parameter.


If you send the value „1“ in the parameter plain, you may define a file name for the PDF here. The browser will then normally display a file download dialog.

Return value

The WebService will return the base64 encoded data of the PDF per default. If there parameter plain was „1“, no base64 encoding will be done.


An example for using the http WebService you may find here:

This example also uses JavaScript to consume the http interface.

HTML example

This simple HTML code provides the http interface for URIs:

<form action="" method="POST">
<input name="plain" type="hidden" value="1" />
<input name="filename" type="hidden" value="webseite.pdf" />
URL: <input name="url" size="80" type="text" value="http://www." /><input type="submit" value="PDF erzeugen" />

You can also simply place this HTML link on your homepage:

<a href="">PDF Download</a>

You really don’t need to do more! Click here to download this page as PDF.

PHP example

This is one way to use the http interface of HTML2PDF with PHP:

class HTML2PDF{
	public static $License=null;

	public static function CreatePDF($url,$header=null,$orientation='Landscape',$background='1',$print='0'){
			'url'			=>	$url,
			'license'		=>	$license,
			'header'		=>	$header,
			'orientation'	=>	$orientation,
			'background'	=>	$background,
			'print'			=>	$print,
			'plain'			=>	'1'
		foreach(array_keys($param) as $key)
		return file_get_contents(''.implode('&',$temp));

This is how this PHP class can be used in PHP code:

HTML2PDF::License='';// Enter the license key here, if available
// Create the PDF and write it to the file "demo.pdf"