Learn how to convert web pages and HTML documents to PDF in PHP using the Pdfcrowd API v2. The API is easy to use and the integration takes only a couple of lines of code.
Learn more about other install options (Composer, GitHub).
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
<?php require 'pdfcrowd.php'; try { // create the API client instance $client = new \Pdfcrowd\HtmlToPdfClient("your_username", "your_apikey"); // run the conversion and write the result to a file $client->convertUrlToFile("http://www.example.com", "example.pdf"); } catch(\Pdfcrowd\Error $why) { // report the error error_log("Pdfcrowd Error: {$why}\n"); // handle the exception here or rethrow and handle it at a higher level throw $why; } ?>
<?php require 'pdfcrowd.php'; try { // create the API client instance $client = new \Pdfcrowd\HtmlToPdfClient("your_username", "your_apikey"); // create output file for conversion result $output_file = fopen("example.pdf", "wb"); // check for a file creation error if (!$output_file) throw new \Exception(error_get_last()['message']); // run the conversion and store the result into a pdf variable $pdf = $client->convertUrl("http://www.example.com"); // write the pdf into the output file $written = fwrite($output_file, $pdf); // check for a file write error if ($written === false) throw new \Exception(error_get_last()['message']); // close the output file fclose($output_file); } catch(\Pdfcrowd\Error $why) { // report the error error_log("Pdfcrowd Error: {$why}\n"); // handle the exception here or rethrow and handle it at a higher level throw $why; } ?>
<?php require 'pdfcrowd.php'; try { // create the API client instance $client = new \Pdfcrowd\HtmlToPdfClient("your_username", "your_apikey"); // create output stream for conversion result $output_stream = fopen("example.pdf", "wb"); // check for a file creation error if (!$output_stream) throw new \Exception(error_get_last()['message']); // run the conversion and write the result into the output stream $client->convertUrlToStream("http://www.example.com", $output_stream); // close the output stream fclose($output_stream); } catch(\Pdfcrowd\Error $why) { // report the error error_log("Pdfcrowd Error: {$why}\n"); // handle the exception here or rethrow and handle it at a higher level throw $why; } ?>
<?php require 'pdfcrowd.php'; try { // create the API client instance $client = new \Pdfcrowd\HtmlToPdfClient("your_username", "your_apikey"); // run the conversion and write the result to a file $client->convertFileToFile("/path/to/MyLayout.html", "MyLayout.pdf"); } catch(\Pdfcrowd\Error $why) { // report the error error_log("Pdfcrowd Error: {$why}\n"); // handle the exception here or rethrow and handle it at a higher level throw $why; } ?>
<?php require 'pdfcrowd.php'; try { // create the API client instance $client = new \Pdfcrowd\HtmlToPdfClient("your_username", "your_apikey"); // create output file for conversion result $output_file = fopen("MyLayout.pdf", "wb"); // check for a file creation error if (!$output_file) throw new \Exception(error_get_last()['message']); // run the conversion and store the result into a pdf variable $pdf = $client->convertFile("/path/to/MyLayout.html"); // write the pdf into the output file $written = fwrite($output_file, $pdf); // check for a file write error if ($written === false) throw new \Exception(error_get_last()['message']); // close the output file fclose($output_file); } catch(\Pdfcrowd\Error $why) { // report the error error_log("Pdfcrowd Error: {$why}\n"); // handle the exception here or rethrow and handle it at a higher level throw $why; } ?>
<?php require 'pdfcrowd.php'; try { // create the API client instance $client = new \Pdfcrowd\HtmlToPdfClient("your_username", "your_apikey"); // create output stream for conversion result $output_stream = fopen("MyLayout.pdf", "wb"); // check for a file creation error if (!$output_stream) throw new \Exception(error_get_last()['message']); // run the conversion and write the result into the output stream $client->convertFileToStream("/path/to/MyLayout.html", $output_stream); // close the output stream fclose($output_stream); } catch(\Pdfcrowd\Error $why) { // report the error error_log("Pdfcrowd Error: {$why}\n"); // handle the exception here or rethrow and handle it at a higher level throw $why; } ?>
<?php require 'pdfcrowd.php'; try { // create the API client instance $client = new \Pdfcrowd\HtmlToPdfClient("your_username", "your_apikey"); // run the conversion and write the result to a file $client->convertStringToFile("<html><body><h1>Hello World!</h1></body></html>", "HelloWorld.pdf"); } catch(\Pdfcrowd\Error $why) { // report the error error_log("Pdfcrowd Error: {$why}\n"); // handle the exception here or rethrow and handle it at a higher level throw $why; } ?>
<?php require 'pdfcrowd.php'; try { // create the API client instance $client = new \Pdfcrowd\HtmlToPdfClient("your_username", "your_apikey"); // create output file for conversion result $output_file = fopen("HelloWorld.pdf", "wb"); // check for a file creation error if (!$output_file) throw new \Exception(error_get_last()['message']); // run the conversion and store the result into a pdf variable $pdf = $client->convertString("<html><body><h1>Hello World!</h1></body></html>"); // write the pdf into the output file $written = fwrite($output_file, $pdf); // check for a file write error if ($written === false) throw new \Exception(error_get_last()['message']); // close the output file fclose($output_file); } catch(\Pdfcrowd\Error $why) { // report the error error_log("Pdfcrowd Error: {$why}\n"); // handle the exception here or rethrow and handle it at a higher level throw $why; } ?>
<?php require 'pdfcrowd.php'; try { // create the API client instance $client = new \Pdfcrowd\HtmlToPdfClient("your_username", "your_apikey"); // create output stream for conversion result $output_stream = fopen("HelloWorld.pdf", "wb"); // check for a file creation error if (!$output_stream) throw new \Exception(error_get_last()['message']); // run the conversion and write the result into the output stream $client->convertStringToStream("<html><body><h1>Hello World!</h1></body></html>", $output_stream); // close the output stream fclose($output_stream); } catch(\Pdfcrowd\Error $why) { // report the error error_log("Pdfcrowd Error: {$why}\n"); // handle the exception here or rethrow and handle it at a higher level throw $why; } ?>
<?php require 'pdfcrowd.php'; try { // create the API client instance $client = new \Pdfcrowd\HtmlToPdfClient("your_username", "your_apikey"); // configure the conversion $client->setDebugLog(true); // run the conversion and write the result to a file $client->convertFileToFile("/path/to/MyLayout.html", "MyLayout.pdf"); // print URL to the debug log echo "Debug log url: " . $client->getDebugLogUrl() . "\n"; // print the number of available conversion credits in your account echo "Remaining credit count: " . $client->getRemainingCreditCount() . "\n"; // print the number of credits consumed by the conversion echo "Consumed credit count: " . $client->getConsumedCreditCount() . "\n"; // print the unique ID of the conversion echo "Job id: " . $client->getJobId() . "\n"; // print the total number of pages in the output document echo "Page count: " . $client->getPageCount() . "\n"; // print the size of the output in bytes echo "Output size: " . $client->getOutputSize() . "\n"; } catch(\Pdfcrowd\Error $why) { // report the error error_log("Pdfcrowd Error: {$why}\n"); // handle the exception here or rethrow and handle it at a higher level throw $why; } ?>
<?php require 'pdfcrowd.php'; try { // create the API client instance $client = new \Pdfcrowd\HtmlToPdfClient("your_username", "your_apikey"); // configure the conversion $client->setPageSize("Letter"); $client->setOrientation("landscape"); $client->setNoMargins(true); // run the conversion and write the result to a file $client->convertUrlToFile("http://www.example.com", "letter_landscape.pdf"); } catch(\Pdfcrowd\Error $why) { // report the error error_log("Pdfcrowd Error: {$why}\n"); // handle the exception here or rethrow and handle it at a higher level throw $why; } ?>
<?php require 'pdfcrowd.php'; try { // create the API client instance $client = new \Pdfcrowd\HtmlToPdfClient("your_username", "your_apikey"); // configure the conversion $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"); // run the conversion and write the result to a file $client->convertUrlToFile("http://www.example.com", "header_footer.pdf"); } catch(\Pdfcrowd\Error $why) { // report the error error_log("Pdfcrowd Error: {$why}\n"); // handle the exception here or rethrow and handle it at a higher level throw $why; } ?>
<?php require 'pdfcrowd.php'; try { // create the API client instance $client = new \Pdfcrowd\HtmlToPdfClient("your_username", "your_apikey"); // configure the conversion $client->setScaleFactor(300); // run the conversion and write the result to a file $client->convertUrlToFile("http://www.example.com", "zoom_300.pdf"); } catch(\Pdfcrowd\Error $why) { // report the error error_log("Pdfcrowd Error: {$why}\n"); // handle the exception here or rethrow and handle it at a higher level throw $why; } ?>
<?php require 'pdfcrowd.php'; try { // create the API client instance $client = new \Pdfcrowd\HtmlToPdfClient("your_username", "your_apikey"); // configure the conversion $client->setAuthor("Pdfcrowd"); $client->setTitle("Hello"); $client->setSubject("Demo"); $client->setKeywords("Pdfcrowd,demo"); // run the conversion and write the result to a file $client->convertUrlToFile("http://www.example.com", "with_metadata.pdf"); } catch(\Pdfcrowd\Error $why) { // report the error error_log("Pdfcrowd Error: {$why}\n"); // handle the exception here or rethrow and handle it at a higher level throw $why; } ?>
<?php require 'pdfcrowd.php'; try { // create the API client instance $client = new \Pdfcrowd\HtmlToPdfClient("your_username", "your_apikey"); // configure the conversion $client->setPageLayout("single-page"); $client->setPageMode("full-screen"); $client->setInitialZoomType("fit-page"); $client->setOrientation("landscape"); $client->setNoMargins(true); // run the conversion and write the result to a file $client->convertUrlToFile("https://pdfcrowd.com/doc/api/", "slide_show.pdf"); } catch(\Pdfcrowd\Error $why) { // report the error error_log("Pdfcrowd Error: {$why}\n"); // handle the exception here or rethrow and handle it at a higher level throw $why; } ?>
<?php require 'pdfcrowd.php'; try { // create the API client instance $client = new \Pdfcrowd\HtmlToPdfClient("your_username", "your_apikey"); // configure the conversion $client->setElementToConvert("#main"); // run the conversion and write the result to a file $client->convertUrlToFile("https://pdfcrowd.com/doc/api/", "html_part.pdf"); } catch(\Pdfcrowd\Error $why) { // report the error error_log("Pdfcrowd Error: {$why}\n"); // handle the exception here or rethrow and handle it at a higher level throw $why; } ?>
<?php require 'pdfcrowd.php'; try { // create the API client instance $client = new \Pdfcrowd\HtmlToPdfClient("your_username", "your_apikey"); // configure the conversion $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)"); // run the conversion and write the result to a file $client->convertUrlToFile("http://www.example.com", "html_inject.pdf"); } catch(\Pdfcrowd\Error $why) { // report the error error_log("Pdfcrowd Error: {$why}\n"); // handle the exception here or rethrow and handle it at a higher level throw $why; } ?>
<?php require 'pdfcrowd.php'; try { // create the API client instance $client = new \Pdfcrowd\HtmlToPdfClient("your_username", "your_apikey"); // configure the conversion $client->setCustomJavascript("libPdfcrowd.highlightHtmlElements({backgroundColor: 'rgba(255, 191, 0, 0.1)', borderColor:null})"); // run the conversion and write the result to a file $client->convertUrlToFile("http://www.example.com", "highlight_background.pdf"); } catch(\Pdfcrowd\Error $why) { // report the error error_log("Pdfcrowd Error: {$why}\n"); // handle the exception here or rethrow and handle it at a higher level throw $why; } ?>
<?php require 'pdfcrowd.php'; try { // create the API client instance $client = new \Pdfcrowd\HtmlToPdfClient("your_username", "your_apikey"); // configure the conversion $client->setCustomJavascript("libPdfcrowd.highlightHtmlElements({borderColor: 'orange', backgroundColor: null, padding: '4px', margin: '4px'})"); // run the conversion and write the result to a file $client->convertUrlToFile("http://www.example.com", "highlight_borders.pdf"); } catch(\Pdfcrowd\Error $why) { // report the error error_log("Pdfcrowd Error: {$why}\n"); // handle the exception here or rethrow and handle it at a higher level throw $why; } ?>
Check out the Github repository with examples of Pdfcrowd API integration into various web frameworks. For PHP see:
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:
You can also use these HTML related features:
pdfcrowd-remove
- sets display:none!important
on the elementpdfcrowd-hide
- sets visibility:hidden!important
on the element<div style="page-break-before:always"></div>
img { page-break-inside:avoid }
try { // call the API } catch(\Pdfcrowd\Error $why) { // print error error_log("Pdfcrowd Error: {$why}\n"); // print just error code error_log("Pdfcrowd Error Code: {$why->getCode()}\n"); // print just error message error_log("Pdfcrowd Error Message: {$why->getMessage()}\n"); // or handle the error in your way }
libPdfcrowd.highlightHtmlElements
method call to visualize all HTML elements. See the example and helper JavaScript library documentation.
Conversion from HTML to PDF. All setter methods return HtmlToPdfClient object unless otherwise specified.
function __construct($user_name, $api_key)
Parameter | Description | Default |
---|---|---|
user_name |
Your username at Pdfcrowd.
|
|
api_key |
Your API key.
|
function convertUrl($url)
Parameter | Description | Default |
---|---|---|
url |
The address of the web page to convert.
The supported protocols are http:// and https://.
|
function convertUrlToStream($url, $out_stream)
Parameter | Description | Default |
---|---|---|
url |
The address of the web page to convert.
The supported protocols are http:// and https://.
|
|
out_stream |
The output stream that will contain the conversion output.
|
function convertUrlToFile($url, $file_path)
Parameter | Description | Default |
---|---|---|
url |
The address of the web page to convert.
The supported protocols are http:// and https://.
|
|
file_path |
The output file path.
The string must not be empty.
|
function convertFile($file)
Parameter | Description | Default |
---|---|---|
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.
|
function convertFileToStream($file, $out_stream)
Parameter | Description | Default |
---|---|---|
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.
|
|
out_stream |
The output stream that will contain the conversion output.
|
function convertFileToFile($file, $file_path)
Parameter | Description | Default |
---|---|---|
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.
|
|
file_path |
The output file path.
The string must not be empty.
|
function convertString($text)
Parameter | Description | Default |
---|---|---|
text |
The string content to convert.
The string must not be empty.
|
function convertStringToStream($text, $out_stream)
Parameter | Description | Default |
---|---|---|
text |
The string content to convert.
The string must not be empty.
|
|
out_stream |
The output stream that will contain the conversion output.
|
function convertStringToFile($text, $file_path)
Parameter | Description | Default |
---|---|---|
text |
The string content to convert.
The string must not be empty.
|
|
file_path |
The output file path.
The string must not be empty.
|
function setPageSize($page_size)
Parameter | Description | Default |
---|---|---|
page_size |
Allowed values:
|
A4 |
function setPageWidth($page_width)
Parameter | Description | Default |
---|---|---|
page_width |
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
8.27in |
setPageWidth("300mm")
setPageWidth("9.5in")
function setPageHeight($page_height)
Parameter | Description | Default |
---|---|---|
page_height |
Can be -1 or specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
11.7in |
setPageHeight("350mm")
setPageHeight("15.25in")
setPageHeight("-1")
function setPageDimensions($width, $height)
Parameter | Description | Default |
---|---|---|
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).
|
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).
|
11.7in |
setPageDimensions("300mm", "350mm")
setPageDimensions("9.5in", "15.25in")
setPageDimensions("372mm", "520pt")
function setOrientation($orientation)
Parameter | Description | Default |
---|---|---|
orientation |
Allowed values:
|
portrait |
function setMarginTop($margin_top)
Parameter | Description | Default |
---|---|---|
margin_top |
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
0.4in |
setMarginTop("1in")
setMarginTop("2.5cm")
function setMarginRight($margin_right)
Parameter | Description | Default |
---|---|---|
margin_right |
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
0.4in |
setMarginRight("1in")
setMarginRight("2.5cm")
function setMarginBottom($margin_bottom)
Parameter | Description | Default |
---|---|---|
margin_bottom |
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
0.4in |
setMarginBottom("1in")
setMarginBottom("2.5cm")
function setMarginLeft($margin_left)
Parameter | Description | Default |
---|---|---|
margin_left |
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
0.4in |
setMarginLeft("1in")
setMarginLeft("2.5cm")
function setNoMargins($no_margins)
Parameter | Description | Default |
---|---|---|
no_margins |
Set to true to disable margins.
|
false |
function setPageMargins($top, $right, $bottom, $left)
Parameter | Description | Default |
---|---|---|
top |
Set the output page top margin.
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
0.4in |
right |
Set the output page right margin.
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
0.4in |
bottom |
Set the output page bottom margin.
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
0.4in |
left |
Set the output page left margin.
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
0.4in |
function setHeaderUrl($header_url)
Parameter | Description | Default |
---|---|---|
header_url |
The supported protocols are http:// and https://.
|
setHeaderUrl("http://myserver.com/header.html")
function setHeaderHtml($header_html)
Parameter | Description | Default |
---|---|---|
header_html |
The string must not be empty.
|
setHeaderHtml("Page <span class='pdfcrowd-page-number'></span> of <span class='pdfcrowd-page-count'></span> pages")
function setHeaderHeight($header_height)
Parameter | Description | Default |
---|---|---|
header_height |
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
0.5in |
setHeaderHeight("30mm")
setHeaderHeight("1in")
Parameter | Description | Default |
---|---|---|
footer_url |
The supported protocols are http:// and https://.
|
setFooterUrl("http://myserver.com/header.html")
Parameter | Description | Default |
---|---|---|
footer_html |
The string must not be empty.
|
setFooterHtml("Page <span class='pdfcrowd-page-number'></span> of <span class='pdfcrowd-page-count'></span> pages")
Parameter | Description | Default |
---|---|---|
footer_height |
Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
0.5in |
setFooterHeight("30mm")
setFooterHeight("1in")
function setPrintPageRange($pages)
Parameter | Description | Default |
---|---|---|
pages |
A comma seperated list of page numbers or ranges.
|
setPrintPageRange("2")
setPrintPageRange("1,3")
setPrintPageRange("2-")
setPrintPageRange("-3")
setPrintPageRange("3,6-9")
function setPageBackgroundColor($page_background_color)
Parameter | Description | Default |
---|---|---|
page_background_color |
The value must be in RRGGBB or RRGGBBAA hexadecimal format.
|
setPageBackgroundColor("FF0000")
setPageBackgroundColor("00ff00")
setPageBackgroundColor("00ff0080")
function setPageWatermark($page_watermark)
Parameter | Description | Default |
---|---|---|
page_watermark |
The file path to a local watermark PDF file.
The file must exist and not be empty.
|
function setMultipageWatermark($multipage_watermark)
Parameter | Description | Default |
---|---|---|
multipage_watermark |
The file path to a local watermark PDF file.
The file must exist and not be empty.
|
function setPageBackground($page_background)
Parameter | Description | Default |
---|---|---|
page_background |
The file path to a local background PDF file.
The file must exist and not be empty.
|
function setMultipageBackground($multipage_background)
Parameter | Description | Default |
---|---|---|
multipage_background |
The file path to a local background PDF file.
The file must exist and not be empty.
|
function setExcludeHeaderOnPages($pages)
Parameter | Description | Default |
---|---|---|
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 seperated list of page numbers.
|
setExcludeHeaderOnPages("2")
setExcludeHeaderOnPages("1,-1")
Parameter | Description | Default |
---|---|---|
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 seperated list of page numbers.
|
setExcludeFooterOnPages("2")
setExcludeFooterOnPages("1,-1")
function setPageNumberingOffset($offset)
Parameter | Description | Default |
---|---|---|
offset |
Integer specifying page offset.
|
0 |
setPageNumberingOffset(1)
setPageNumberingOffset(-10)
function setNoBackground($no_background)
Parameter | Description | Default |
---|---|---|
no_background |
Set to true to disable the background graphics.
|
false |
function setDisableJavascript($disable_javascript)
Parameter | Description | Default |
---|---|---|
disable_javascript |
Set to true to disable JavaScript in web pages.
|
false |
function setDisableImageLoading($disable_image_loading)
Parameter | Description | Default |
---|---|---|
disable_image_loading |
Set to true to disable loading of images.
|
false |
function setDisableRemoteFonts($disable_remote_fonts)
Parameter | Description | Default |
---|---|---|
disable_remote_fonts |
Set to true disable loading remote fonts.
|
false |
function setBlockAds($block_ads)
Parameter | Description | Default |
---|---|---|
block_ads |
Set to true to block ads in web pages.
|
false |
function setDefaultEncoding($default_encoding)
Parameter | Description | Default |
---|---|---|
default_encoding |
The text encoding of the HTML content.
|
auto detect |
function setHttpAuth($user_name, $password)
Parameter | Description | Default |
---|---|---|
user_name |
Set the HTTP authentication user name.
|
|
password |
Set the HTTP authentication password.
|
function setUsePrintMedia($use_print_media)
Parameter | Description | Default |
---|---|---|
use_print_media |
Set to true to use the print version of the page.
|
false |
function setNoXpdfcrowdHeader($no_xpdfcrowd_header)
Parameter | Description | Default |
---|---|---|
no_xpdfcrowd_header |
Set to true to disable sending X-Pdfcrowd HTTP header.
|
false |
function setCookies($cookies)
Parameter | Description | Default |
---|---|---|
cookies |
The cookie string.
|
setCookies("session=6d7184b3bf35;token=2710")
function setVerifySslCertificates($verify_ssl_certificates)
Parameter | Description | Default |
---|---|---|
verify_ssl_certificates |
Set to true to enable SSL certificate verification.
|
false |
function setFailOnMainUrlError($fail_on_error)
Parameter | Description | Default |
---|---|---|
fail_on_error |
Set to true to abort the conversion.
|
false |
function setFailOnAnyUrlError($fail_on_error)
Parameter | Description | Default |
---|---|---|
fail_on_error |
Set to true to abort the conversion.
|
false |
function setCustomJavascript($custom_javascript)
Parameter | Description | Default |
---|---|---|
custom_javascript |
A string containing a JavaScript code.
The string must not be empty.
|
function setCustomHttpHeader($custom_http_header)
Parameter | Description | Default |
---|---|---|
custom_http_header |
A string containing the header name and value separated by a colon.
|
setCustomHttpHeader("X-My-Client-ID:k2017-12345")
function setJavascriptDelay($javascript_delay)
Parameter | Description | Default |
---|---|---|
javascript_delay |
The number of milliseconds to wait.
Must be a positive integer number or 0.
|
200 |
function setElementToConvert($selectors)
Parameter | Description | Default |
---|---|---|
selectors |
One or more CSS selectors separated by commas.
The string must not be empty.
|
setElementToConvert("#main-content")
setElementToConvert(".main-content")
setElementToConvert("table")
setElementToConvert("table, #main-content")
setElementToConvert("div.user-panel.main p.article")
function setElementToConvertMode($mode)
Parameter | Description | Default |
---|---|---|
mode |
Allowed values:
|
cut-out |
function setWaitForElement($selectors)
Parameter | Description | Default |
---|---|---|
selectors |
One or more CSS selectors separated by commas.
The string must not be empty.
|
setWaitForElement("#main-content")
setWaitForElement(".main-content")
setWaitForElement("table")
setWaitForElement("table, #main-content")
setWaitForElement("div.user-panel.main p.article")
function setViewport($width, $height)
Parameter | Description | Default |
---|---|---|
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-7680.
|
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.
|
768 |
function setRenderingMode($rendering_mode)
Parameter | Description | Default |
---|---|---|
rendering_mode |
The rendering mode.
Allowed values:
|
default |
function setScaleFactor($scale_factor)
Parameter | Description | Default |
---|---|---|
scale_factor |
The percentage value.
The value must be in the range 10-500.
|
100 |
Parameter | Description | Default |
---|---|---|
header_footer_scale_factor |
The percentage value.
The value must be in the range 10-500.
|
100 |
function setDisableSmartShrinking($disable_smart_shrinking)
Parameter | Description | Default |
---|---|---|
disable_smart_shrinking |
Set to true to disable the intelligent shrinking strategy.
|
false |
function setJpegQuality($jpeg_quality)
Parameter | Description | Default |
---|---|---|
jpeg_quality |
The percentage value.
The value must be in the range 1-100.
|
100 |
function setConvertImagesToJpeg($convert_images_to_jpeg)
Parameter | Description | Default |
---|---|---|
convert_images_to_jpeg |
The image category.
Allowed values:
|
none |
function setImageDpi($image_dpi)
Parameter | Description | Default |
---|---|---|
image_dpi |
The DPI value.
Must be a positive integer number or 0.
|
0 |
setImageDpi(0)
setImageDpi(72)
setImageDpi(96)
setImageDpi(150)
setImageDpi(300)
Miscellaneous values for PDF output.
function setLinearize($linearize)
Parameter | Description | Default |
---|---|---|
linearize |
Set to true to create linearized PDF.
|
false |
function setEncrypt($encrypt)
Parameter | Description | Default |
---|---|---|
encrypt |
Set to true to enable PDF encryption.
|
false |
function setUserPassword($user_password)
Parameter | Description | Default |
---|---|---|
user_password |
The user password.
|
function setOwnerPassword($owner_password)
Parameter | Description | Default |
---|---|---|
owner_password |
The owner password.
|
function setNoPrint($no_print)
Parameter | Description | Default |
---|---|---|
no_print |
Set to true to set the no-print flag in the output PDF.
|
false |
function setNoModify($no_modify)
Parameter | Description | Default |
---|---|---|
no_modify |
Set to true to set the read-only only flag in the output PDF.
|
false |
function setNoCopy($no_copy)
Parameter | Description | Default |
---|---|---|
no_copy |
Set to true to set the no-copy flag in the output PDF.
|
false |
function setTitle($title)
Parameter | Description | Default |
---|---|---|
title |
The title.
|
function setSubject($subject)
Parameter | Description | Default |
---|---|---|
subject |
The subject.
|
function setAuthor($author)
Parameter | Description | Default |
---|---|---|
author |
The author.
|
function setKeywords($keywords)
Parameter | Description | Default |
---|---|---|
keywords |
The string with the keywords.
|
These preferences specify how a PDF viewer should present the document. The preferences may be ignored by some PDF viewers.
function setPageLayout($page_layout)
Parameter | Description | Default |
---|---|---|
page_layout |
Allowed values:
|
function setPageMode($page_mode)
Parameter | Description | Default |
---|---|---|
page_mode |
Allowed values:
|
function setInitialZoomType($initial_zoom_type)
Parameter | Description | Default |
---|---|---|
initial_zoom_type |
Allowed values:
|
function setInitialPage($initial_page)
Parameter | Description | Default |
---|---|---|
initial_page |
Must be a positive integer number.
|
function setInitialZoom($initial_zoom)
Parameter | Description | Default |
---|---|---|
initial_zoom |
Must be a positive integer number.
|
function setHideToolbar($hide_toolbar)
Parameter | Description | Default |
---|---|---|
hide_toolbar |
Set to true to hide tool bars.
|
false |
Parameter | Description | Default |
---|---|---|
hide_menubar |
Set to true to hide the menu bar.
|
false |
function setHideWindowUi($hide_window_ui)
Parameter | Description | Default |
---|---|---|
hide_window_ui |
Set to true to hide ui elements.
|
false |
function setFitWindow($fit_window)
Parameter | Description | Default |
---|---|---|
fit_window |
Set to true to resize the window.
|
false |
function setCenterWindow($center_window)
Parameter | Description | Default |
---|---|---|
center_window |
Set to true to center the window.
|
false |
function setDisplayTitle($display_title)
Parameter | Description | Default |
---|---|---|
display_title |
Set to true to display the title.
|
false |
function setRightToLeft($right_to_left)
Parameter | Description | Default |
---|---|---|
right_to_left |
Set to true to set right-to-left reading order.
|
false |
function setDebugLog($debug_log)
Parameter | Description | Default |
---|---|---|
debug_log |
Set to true to enable the debug logging.
|
false |
function getDebugLogUrl()
function getRemainingCreditCount()
function getConsumedCreditCount()
function getJobId()
function getPageCount()
function getOutputSize()
function setTag($tag)
Parameter | Description | Default |
---|---|---|
tag |
A string with the custom tag.
|
function setHttpProxy($http_proxy)
Parameter | Description | Default |
---|---|---|
http_proxy |
The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
setHttpProxy("myproxy.com:8080")
setHttpProxy("113.25.84.10:33333")
function setHttpsProxy($https_proxy)
Parameter | Description | Default |
---|---|---|
https_proxy |
The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
setHttpsProxy("myproxy.com:443")
setHttpsProxy("113.25.84.10:44333")
function setClientCertificate($client_certificate)
Parameter | Description | Default |
---|---|---|
client_certificate |
The file must be in PKCS12 format.
The file must exist and not be empty.
|
function setClientCertificatePassword($client_certificate_password)
Parameter | Description | Default |
---|---|---|
client_certificate_password |
function setUseHttp($use_http)
Parameter | Description | Default |
---|---|---|
use_http |
Set to true to use HTTP.
|
false |
function setUserAgent($user_agent)
Parameter | Description | Default |
---|---|---|
user_agent |
The user agent string.
|
pdfcrowd_php_client/4.4.2 (http://pdfcrowd.com) |
function setProxy($host, $port, $user_name, $password)
Parameter | Description | Default |
---|---|---|
host |
The proxy hostname.
|
|
port |
The proxy port.
|
|
user_name |
The username.
|
|
password |
The password.
|
function setRetryCount($retry_count)
Parameter | Description | Default |
---|---|---|
retry_count |
Number of retries wanted.
|
1 |