Advanced Options
 

How to use / insert ImPDF.com in your own site

Just link the text or image people will use for downloading a specific page/url:


http://impdf.com?url=impdf.com

for example:

<a href="http://impdf.com?url=impdf.com">download this page as PDF</a> 

will create a text link that looks like this:

Download this page as PDF


How to use on your server?
 

Synopsis (the first -O <filename> is wget's own output file option): 

wget -O impdf.pdf "impdf.com?url=impdf.com&-O=Landscape&--header-left=hello"


General Options:
You can mix-and-match the underneath options to customize the pdf to your needs.

For example, if you want a landscaped PDF you add -O=Landscape or --orientation=Landscape and if you want to add a header with text aligned to the left you would use --header-left=hiYou can also alter the default filename by providing the --filename=ot.pdf option.

These three options combined in one text link would look like this:

 

<a href="http://impdf.com?url=impdf.com&-O=Landscape&--header-left=hi&--filename=ot.pdf">pdf</a> 

Notice that in the above example the ampersand "&" sign separates each option, and the separating character for a parameter is an equals "=" sign. You will need to url escape any reserved url characters for option values.

Command Line Options:
imhtmltopdf [OPTIONS]... <input file> [More input files] <output file>

Description:
Converts one or more HTML pages into a PDF document.

General Options:  
  --filename <filename> Set the filename to download, default is a filename made from the url.
-b --book Set the options one would usually set when printing a book
  --collate Collate when printing multiple copies
  --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
-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
  --extended-help Display more extensive help, detailing less common command switches
-h --help Display help
-O --orientation <orientation> Set orientation to Landscape or Portrait
-s --page-size <size> Set paper size to: A4, Letter, etc.
  --password <password> HTTP Authentication password
-p --proxy <proxy> Use a proxy
-q --quiet Be less verbose
-t --toc Insert a table of content in the beginning of the document
  --username <username> HTTP Authentication username
-V --version Output version information an exit
Extended Options:  
  --allow <path> Allow the file or files from the specified folder to be loaded (repeatable)
-b --book Set the options one would usually 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)
  --debug-javascript Show javascript debugging output
-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 no make links to remote web pages
  --disable-internal-links Do no make local links
-n --disable-javascript Do not allow web pages to run javascript
  --disable-pdf-compression Do not use lossless compression on pdf objects
  --disable-smart-shrinking Disable the intelligent shrinking strategy used by WebKit that makes the pixel/dpi ratio none constant
  --disallow-local-file-access Do not allowed conversion of a local file to read in other local files, unless explicitly allowed with --allow
-d --dpi <dpi> Change the dpi explicitly (this has no effect on X11 based systems)
  --enable-plugins Enable installed plug-ins (such as flash, etc.)
  --encoding <encoding> Set the default text encoding, for input
  --extended-help Display more extensive help, detailing less common command switches
  --forms Turn HTML form fields into pdf form fields
-g --grayscale PDF will be generated in grayscale
-h --help Display help
  --htmldoc Output program html help
  --ignore-load-errors Ignore pages that claimes to have encountered an error during loading
-l --lowquality Generates lower quality pdf/ps. Useful to shrink the result document space
  --manpage Output program man page
-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 additional file (repeatable)
  --print-media-type Use print media-type instead of screen
-p --proxy <proxy> Use a proxy
-q --quiet Be less verbose
  --read-args-from-stdin Read command line arguments from stdin
  --readme Output program readme
  --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> The title of the generated pdf file (The title of the first document is used if not specified)
-t --toc Insert a table of content 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)
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:  
  --dump-outline <file> Dump the outline to a file
  --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 below table,

Constant Value Description
A0 5 841 x 1189 mm
A1 6 594 x 841 mm
A2 7 420 x 594 mm
A3 8 297 x 420 mm
A4 0 210 x 297 mm, 8.26 x 11.69 inches
A5 9 148 x 210 mm
A6 10 105 x 148 mm
A7 11 74 x 105 mm
A8 12 52 x 74 mm
A9 13 37 x 52 mm
B0 14 1000 x 1414 mm
B1 15 707 x 1000 mm
B2 17 500 x 707 mm
B3 18 353 x 500 mm
B4 19 250 x 353 mm
B5 1 176 x 250 mm, 6.93 x 9.84 inches
B6 20 125 x 176 mm
B7 21 88 x 125 mm
B8 22 62 x 88 mm
B9 23 33 x 62 mm
B10 16 31 x 44 mm
C5E 24 163 x 229 mm
Comm10E 25 105 x 241 mm, U.S. Common 10 Envelope
DLE 26 110 x 220 mm
Executive 4 7.5 x 10 inches, 190.5 x 254 mm
Folio 27 210 x 330 mm
Ledger 28 431.8 x 279.4 mm
Legal 3 8.5 x 14 inches, 215.9 x 355.6 mm
Letter 2 8.5 x 11 inches, 215.9 x 279.4 mm
Tabloid 29 279.4 x 431.8 mm

For a more fine grained control over the page size the --page-height and --page-width options may be used.

Specifying A Proxy:
By default proxy information will be read from the environment variables: proxy,
all_proxy and http_proxy, proxy options can also by specified with the -p switch

<type> := "http://" | "socks5://"
<serif> := <username> (":" <password>)? "@"
<proxy> := "None" | <type>? <sering>? <host> (":" <port>)?

Here are some examples (In case you are unfamiliar with the BNF):

http://user:password@myproxyserver:8080
socks5://myproxyserver
None

Footers And Headers:
Headers and footers can be added to the document by the --header-* and --footer* arguments respectfully. In header and footer text string supplied to e.g. --header-left, the following variables will be substituted.
 

* [page] Replaced by the number of the pages currently being printed
* [frompage] Replaced by the number of the first page to be printed
* [topage] Replaced by the number of the last page to be printed
* [webpage] Replaced by the URL of the page being printed
* [section] Replaced by the name of the current section
* [subsection] Replaced by the name of the current subsection
* [date] Replaced by the current date in system local format
* [time] Replaced by the current time in system local format

As an example specifying --header-right "Page [page] of [toPage]", will result in the text "Page x of y" where x is the number of the current page and y is the number of the last page, to appear in the upper left corner in the document.

Headers and footers can also be supplied with HTML documents. As an example one could specify "--header-html header.html", and use the following content in header.html:

<html><head><script>
function subst()
{
    var vars={};
    var x=document.location.search.substring(1).split('&');
    for(var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);}
    var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
    for(var i in x) {
        var y = document.getElementsByClassName(x[i]);
        for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
    }
}
</script></head><body style="border:0; margin: 0;" onload="subst()">
<table style="border-bottom: 1px solid black; width: 100%">
  <tr>
    <td class="section"></td>
      <td style="text-align:right">
        Page <span class="page"></span> of <span class="topage"></span>
      </td>
    </tr>
  </table>
</body></html>

As can be seen from the example, the arguments are sent to the header/footer html documents in get fashion.

Outlines:
imhtmltopdf has support for PDF outlines also known as bookmarks, this can be enabled by specifying the --outline switch. The outlines are generated based on the <h?> tags, for a in-depth description of how this is done see the "Table Of Contest" section.

The outline tree can sometimes be very deep, if the <h?> tags where spread to generous in the HTML document. The --outline-depth switch can be used to bound this.


Home | Privacy Policy | Terms of Use | Legal Statement | Links | Contact