Please enable JavaScript to view this site.

Navigation: Developer Information > Command Line Interface

Command Line HTML To PDF

Scroll Prev Top Next More

HTML To PDF Command Line Format

 

win2pdfd.exe html2pdf "sourcehtml" "destpdf"

win2pdfd.exe html2pdf "sourcehtml" "destpdf" "papersize"

win2pdfd.exe html2pdf "sourcehtml" "destpdf" "papersize" timeout

win2pdfd.exe html2pdf "sourcehtml" "destpdf" "papersize" timeout marginleft margintop marginright marginbottom

win2pdfd.exe html2pdf "sourcehtml" "destpdf" "papersize" timeout marginleft margintop marginright marginbottom "headertemplate" "footertemplate"

 

 

Convert the HTML file or web page specified by "sourcehtml" to a PDF file named "destpdf".

 

If the "papersize" is specified, it can be one of:

letter

letter-landscape

legal

legal-landscape

tabloid

tabloid-landscape

A2

A2-landscape

A3

A3-landscape

A4

A4-landscape

A5

A5-landscape

CSheet

CSheet-landscape

DSheet

DSheet-landscape

ESheet

ESheet-landscape

 

The "-landscape" papersize variations change the orientation to landscape.

 

Any file names that contain spaces must be enclosed with quotation marks.

 

The optional "timeout" parameter is specified in milliseconds.  If no timeout is specified, the default is 30000 (30 seconds).

 

The optional "marginleft", "margintop", "marginright", and "marginbottom" parameters are specified in points (1/72 inch).  If no margin is specified, 0 margins are used.

 

The optional "headertemplate" and "footertemplate" parameters specify a HTML file to be rendered in the header or footer of the PDF. To specify only a header or footer, set the other parameter to an empty string "".

 

When creating the PDF, the following classes can be used to render information into the PDF:

date (formatted creation date).

title (document title).

url (document location).

pageNumber (current page number)

totalPages (total pages in the document)

 

Images can be included in the header or footer template if they are encoded as data URIs.

 

For example, placing the following HTML in a file and referencing it as the "footertemplate" parameter will put the URL and page number at the bottom of each page in the converted PDF:

<div style='font-size:10px;padding-left:10px;'>

    <span class='url'></span>

    <div>Page <span class='pageNumber'></span> of <span class='totalPages'></span></div>

</div>

 

This feature requires a licensed version of Win2PDF. Contact us for a time limited evaluation license.

 

Returns 0 on success, and a Windows system error code on failure.