Alongside the web interface, we also support an API for converting webpages into pdf's.
The API is free to use and does not have any restrictions. See our terms and privacy policy for details.
A simple http server call can be made to convert any url to a pdf
where {url} is the (url encoded) location of webpage beginning with http://
The pdf is then generated by our servers and sent to the requesting machine.
There are numerous options available for customizing, manipulating or adding data to a pdf.
They can be used by adding parameters to the requested url
For example, if you want a landscaped pdf you add
--orientation=Landscape
and if you want to add a header with text aligned to the left you would use
--header-left=myHeader
You can also alter the default filename by providing a filename parameter
--filename=myfile.pdf
These three options combined in call would look like this:
http://pdfmyurl.com?url=mysite.com&-O=Landscape&--header-left=myHeader&-...
--html Don't pdf the url,but pdf the html posted content.
--png Don't make a pdf but make a png of the content.
--thumb Don't make a pdf but make a thumbnail of the content. With default height 100.
--thumb height Don't make a pdf but make a thumbnail of the content. With height as a parameter.
--original-url Set the --header-right parameter to be the url of
the created pdf page.
--filename <filename> Set the filename to download, default is a
filename made from the url.
-O, --orientation <orientation> Set orientation to Landscape or Portrait
-s, --page-size <size> Set paper size to: A4, Letter, etc.
-p, --proxy <proxy> Use a proxy
--username <username> HTTP Authentication username
--password <password> HTTP Authentication password
--custom-header <name> <value> Set an additional HTTP header (single)
-b, --book Set the standard options normally set when printing a book
--collate Collate when printing multiple copies
--cookie <name> <value> Set an additional cookie (repeatable)
--cookie-jar <path> Read and write cookies from and to the supplied cookie jar file
--copies <number> Number of copies to print into the pdf file (default 1)
--cover <url> Use html document as cover. It will be
inserted before the toc with no headers and footers
--custom-header <name> <value> Set an additional HTTP header (repeatable)
-H, --default-header Add a default header, with the name of the
page to the left, and the page number to
the right, this is short for:
--header-left='[webpage]'
--header-right='[page]/[toPage]' --top 2cm
--header-line
--disable-external-links Do not make links to remote web pages
--disable-internal-links Do not make local links
-n, --disable-javascript Do not allow web pages to run javascript
--disable-smart-shrinking Disable the pixel/dpi ratio intelligent shrinking strategy
-d, --dpi <dpi> Change the dpi explicitly
--encoding <encoding> Set the default text encoding, for input
-g, --grayscale Generate PDF in grayscale
-l, --lowquality Generates lower quality pdf/ps. Useful to
shrink the result document space
-B, --margin-bottom <unitreal> Set the page bottom margin (default 10mm)
-L, --margin-left <unitreal> Set the page left margin (default 10mm)
-R, --margin-right <unitreal> Set the page right margin (default 10mm)
-T, --margin-top <unitreal> Set the page top margin (default 10mm)
--minimum-font-size <int> Minimum font size (default 5)
--no-background Do not print background
-O, --orientation <orientation> Set orientation to Landscape or Portrait
--page-height <unitreal> Page height (default unit millimeter)
--page-offset <offset> Set the starting page number (default 1)
-s, --page-size <size> Set paper size to: A4, Letter, etc.
--page-width <unitreal> Page width (default unit millimeter)
--password <password> HTTP Authentication password
--post <name> <value> Add an additional post field (repeatable)
--post-file <name> <path> Post an aditional file (repeatable)
--print-media-type Use print media-type instead of screen
-p, --proxy <proxy> Use a proxy
-q, --quiet Be less verbose
--redirect-delay <msec> Wait some milliseconds for js-redirects (default 200)
--replace <name> <value> Replace [name] with value in header and footer (repeatable)
--stop-slow-scripts Stop slow running javascripts
--title <text> Set the title of the generated pdf file (The
title of the first document is used if not specified)
-t, --toc Insert a table of contents in the beginning of the document
--user-style-sheet <url> Specify a user style sheet, to load with every page
--username <username> HTTP Authentication username
-V, --version Output version information an exit
--zoom <float> Use this zoom factor (default 1)
Raw HTML (beta):
--html <HTML code> Converts HTML code into a pdf
PNG (beta):
--png Converts the url to a PNG image file
--thumb Don't make a pdf but make a thumbnail of the content. With default height 100.
--thumb height Don't make a pdf but make a thumbnail of the content. With height as a parameter.
Headers And Footer Options:
--footer-center <text> Centered footer text
--footer-font-name <name> Set footer font name (default Arial)
--footer-font-size <size> Set footer font size (default 11)
--footer-html <url> Adds a html footer
--footer-left <text> Left aligned footer text
--footer-line Display line above the footer
--footer-right <text> Right aligned footer text
--footer-spacing <real> Spacing between footer and content in mm (default 0)
--header-center <text> Centered header text
--header-font-name <name> Set header font name (default Arial)
--header-font-size <size> Set header font size (default 11)
--header-html <url> Adds a html header
--header-left <text> Left aligned header text
--header-line Display line below the header
--header-right <text> Right aligned header text
--header-spacing <real> Spacing between header and content in mm
(default 0)
Table Of Content Options:
--toc-depth <level> Set the depth of the toc (default 3)
--toc-disable-back-links Do not link from section header to toc
--toc-disable-links Do not link from toc to sections
--toc-font-name <name> Set the font used for the toc (default
Arial)
--toc-header-font-name <name> The font of the toc header (if unset use --toc-font-name)
--toc-header-font-size <size> The font size of the toc header (default 15)
--toc-header-text <text> The header text of the toc (default Table Of Contents)
--toc-l1-font-size <size> Set the font size on level 1 of the toc (default 12)
--toc-l1-indentation <num> Set indentation on level 1 of the toc (default 0)
--toc-l2-font-size <size> Set the font size on level 2 of the toc (default 10)
--toc-l2-indentation <num> Set indentation on level 2 of the toc (default 20)
--toc-l3-font-size <size> Set the font size on level 3 of the toc (default 8)
--toc-l3-indentation <num> Set indentation on level 3 of the toc (default 40)
--toc-l4-font-size <size> Set the font size on level 4 of the toc (default 6)
--toc-l4-indentation <num> Set indentation on level 4 of the toc (default 60)
--toc-l5-font-size <size> Set the font size on level 5 of the toc (default 4)
--toc-l5-indentation <num> Set indentation on level 5 of the toc (default 80)
--toc-l6-font-size <size> Set the font size on level 6 of the toc (default 2)
--toc-l6-indentation <num> Set indentation on level 6 of the toc (default 100)
--toc-l7-font-size <size> Set the font size on level 7 of the toc (default 0)
--toc-l7-indentation <num> Set indentation on level 7 of the toc (default 120)
--toc-no-dots Do not use dots, in the toc
Outline Options:
--outline Put an outline into the pdf
--outline-depth <level> Set the depth of the outline (default 4)
Page sizes:
The default page size of the rendered document is A4, but using this
--page-size option. this can be changed to almost anything else, such as: A3,
Letter and Legal. For a full list of supported pages sizes please see
<http://doc.trolltech.com/4.6/qprinter.html#PageSize-enum>.
Comments
Ben (not verified)
Mon, 11/07/2011 - 23:53
Permalink
Great API!
This is an awesome API, gonna save me a lot of time. I'll be sure to share any ideas or new implementations I come up with.
-Ben
Seebz (not verified)
Thu, 12/29/2011 - 11:20
Permalink
Some parameters not working
It seems that "footer-html" and "user-style-sheet" parameters doesn't work.
"header-html" works fine..
Add new comment