Note : we have rolled out a completely revised API in February 2014. The documentation for that is ON THE MAIN SITE. New users will automatically sign up for that. The below information is only for legacy users and they can choose to work with the old API or switch to the new one.
Introduction
Alongside the web interface, we also support an API (Application programming interface) for converting webpages into PDF.
The API is available to our business license holders only and those have unrestricted use, taking into account our terms and privacy policy.
Example Use
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.
Options
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&-…
List of parameters for the URL to PDF API
Function parameters
Parameter | Description |
url | The URL that you want to create a PDF from. |
–html | Don’t PDF the URL,but PDF the HTML content that’s posted |
–localhost-wrapper | Don’t make a PDF from the url, first download the contents of the URL locally (using the command wget -E -H -k -K -p url) and then make a PDF of that URL locally. This fixes stalling issues seen when making PDFs of very big HTML files, but does have issues wrt external styles-sheets using wget (see the unix wget command for known issues. Restrictions/ limitations still apply. Concurrency issues might apply). NOTE: this option is only available for PRIVATE SERVER users |
Page layout parameters
Parameter | Description |
–orientation <orientation> | Set orientation to Landscape or Portrait |
–page-size <size> | Set paper size to any standard size like A3, A4, Letter, Legal etc. Find a full list of supported sizes at the QT website. |
–page-height <unitreal> | Page height (default unit millimeter) |
–page-width <unitreal> | Page width (default unit millimeter) |
–margin-bottom <unitreal> | Set the page bottom margin (default 10mm) |
–margin-left <unitreal> | Set the page left margin (default 10mm) |
–margin-right <unitreal> | Set the page right margin (default 10mm) |
–margin-top <unitreal> | Set the page top margin (default 10mm) |
–book | Set the standard options normally set when printing a book |
–collate | Collate when printing multiple copies |
Headers And Footer parameters
Parameter | Description |
–default-header | Add a default header, with the name of thepage to the left, and the page number to the right, this is short for:–header-left='[webpage]’ –header-right='[page]/[toPage]’ |
–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) |
–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) |
–replace <name> <value> | Replace [name] with value in header and footer (repeatable) |
–page-offset <offset> | Set the starting page number (default 1) |
Conversion parameters
Parameter | Description |
–filename <filename> | Set the filename to download, default is a filename made from the url |
–title <text> | Set the title of the generated PDF (the title of the first document is used if not specified) |
–user-style-sheet <url> | Specify a CSS style sheet that should be used during conversion |
–cover <url> | Use the URL as cover. It will be inserted before the TOC with no headers and footers |
–print-media-type | Use CSS media type ‘print’ instead of ‘screen’ |
–grayscale | Generate PDF in grayscale |
–no-background | Do not render the background |
–lowquality | Generates lower quality PDF. Useful to shrink the size of the resulting document |
–zoom <float> | Use this zoom factor (default 1) |
–disable-external-links | Do not make links to remote web pages |
–disable-internal-links | Do not make local links |
–disable-javascript | Do not allow web pages to run JavaScript |
–redirect-delay <msec> | Wait some milliseconds for JavaScript redirects (default 200) |
Table Of Contents
Parameter | Description |
–toc | Insert a table of contents in the beginning of the document |
–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
Parameter | Description |
–outline | Put an outline into the pdf |
–outline-depth <level> | Set the depth of the outline (default 4) |
Access settings for our rendering engine
Parameter | Description |
–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) |
–cookie <name> <value> | Set an additional cookie (repeatable) |
–post <name> <value> | Add an additional post field (repeatable) |
Special email features
Parameter | Description |
Send the PDF as an email (available to premium users) | |
subject | The subject of the email |
message | The message in the email |
Obsolete parameters
The following function parameters are no longer in use as of January 1st, 2014
Parameter | Description |
–png | Don’t make a PDF but make a PNG image 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 |
–boilerplate | Don’t make a PDF but extract the text from the website, e.g. just the news from a news article |
Hi,
Tried your site and the product looks good.
I tested a potential user for the HTML to PDF conversion and find that a normal page is coming back in LANDSCAPE mode..
http://akropol.com.au/csp/akropol/Invoice.csp?fOrderID=1
I tried..
http://pdfmyurl.com/?url=http://akropol.com.au/csp/akropol/Invoice.csp?fOrderID=1&-orientation=Portrait
but got the same result
Is this a demo limitation or is there something wrong?
Thanks,
Rosti.
Hi Rosti,
If you sign up for a membership you can change the setting Portrait/Landscape yourself as part of one of the many settings you can influence for the conversion.
Thanks!
And the option is
--orientation=Portrait
and not-orientation=Portrait
….PDFmyURL is not free?
pity because there should be a free choice in PDFmyURL
change all my projects to another library but solved
Dear John,
PDFmyURL is still free, but only for personal and non-automated use in the browser.
Thanks for your interest!
How can i use the ‘-disable-external-links’ option?
I did know ‘page-size’ : ‘A0’,
but ‘-disable-external-links’ : ?
What do able the value in there?
Hi Lee,
This documentation is for the old API and is only available to members who subscribed before february 2014 – please refer to the new API documentation at http://pdfmyurl.com/html-to-pdf-api
Thanks!