API (advanced options)

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, whilst current API users can choose to work with the old API or switch to the new one. The documentation for the ‘old’ API is below.

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

http://pdfmyurl.com?url={url}

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

ParameterDescription
urlThe URL that you want to create a PDF from.
–htmlDon’t PDF the URL,but PDF the HTML content that’s posted
–localhost-wrapperDon’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

ParameterDescription
–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)
–bookSet the standard options normally set when printing a book
–collateCollate when printing multiple copies

Headers And Footer parameters

ParameterDescription
–default-headerAdd 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-lineDisplay 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-lineDisplay 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

ParameterDescription
–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-typeUse CSS media type ‘print’ instead of ‘screen’
–grayscaleGenerate PDF in grayscale
–no-backgroundDo not render the background
–lowqualityGenerates lower quality PDF. Useful to shrink the size of the resulting document
–zoom <float>Use this zoom factor (default 1)
–disable-external-linksDo not make links to remote web pages
–disable-internal-linksDo not make local links
–disable-javascriptDo not allow web pages to run JavaScript
–redirect-delay <msec>Wait some milliseconds for JavaScript redirects (default 200)

Table Of Contents

ParameterDescription
–tocInsert a table of contents in the beginning of the document
–toc-depth <level>Set the depth of the toc (default 3)
–toc-disable-back-linksDo not link from section header to toc
–toc-disable-linksDo 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-dotsDo not use dots, in the toc

Outline Options

ParameterDescription
–outlinePut an outline into the pdf
–outline-depth <level>Set the depth of the outline (default 4)

Access settings for our rendering engine

ParameterDescription
–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

ParameterDescription
emailSend the PDF as an email (available to premium users)
subjectThe subject of the email
messageThe message in the email

Obsolete parameters

The following function parameters are no longer in use as of January 1st, 2014

ParameterDescription
–pngDon’t make a PDF but make a PNG image of the content
–thumbDon’t make a PDF but make a thumbnail of the content with default height 100
–thumb heightDon’t make a PDF but make a thumbnail of the content with height as a parameter
–boilerplateDon’t make a PDF but extract the text from the website, e.g. just the news from a news article

7 thoughts on “API (advanced options)

    1. pdfmyurl Post author

      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!

      Reply
      1. john

        PDFmyURL is not free?

        pity because there should be a free choice in PDFmyURL

        change all my projects to another library but solved

        Reply
        1. pdfmyurl Post author

          Dear John,

          PDFmyURL is still free, but only for personal and non-automated use in the browser.

          Thanks for your interest!

          Reply
  1. LEE

    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?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *