HTML to PDF API

The API for converting HTML files to PDF files using Google Chrome browser.

HTML PDF

The API for converting HTML files to PDF files.

Sign Up to try this converter - it’s free! Sign Up to Convert

Copy parameter's URL

Secret

Secret String
Authentication secret must be provided as a query parameter. If omitted, token must be provided.
Show all
Copy parameter's URL

Token

Token String
Authentication token must be provided as a query parameter. If omitted, secret must be provided.
Show all
Copy parameter's URL

File *

File * File
File to be converted. Value can be URL or file content.
Show all
Copy parameter's URL

StoreFile

Store file Bool
Store converted file on our secure server and provides download URL.
Default: False Show all
Copy parameter's URL

FileName

File name String
Converted output file name without extension. The extension will be added automatically.
Show all
Copy parameter's URL

Timeout

Timeout Integer
Conversion timeout in seconds.
Default: 120 Range: 10 .. 1200 Show all
Copy parameter's URL

AuthUsername

Authentication username String
HTTP authentication username. Could be used if conversion web page is protected with HTTP authentication.
Show all
Copy parameter's URL

AuthPassword

Authentication password String
HTTP authentication password. Could be used if conversion web page is protected with HTTP authentication.
Show all
Copy parameter's URL

Cookies

Cookies for the page request String
Set additional cookies for the page request. Exaple: cookiename1=cookievalue1; cookiename2=cookievalue2; cookiename3=cookievalue3
Show all
Copy parameter's URL

PageRange

Page Range String
Set page range. Example 1-10 or 1,2,5.
Default: 1-100 Show all
Copy parameter's URL

ConversionDelay

Conversion delay Integer
Delay in seconds before page load and PDF creation. Sometimes useful to let web page fully load.
Default: 0 Range: 0 .. 30 Show all
Copy parameter's URL

AdBlock

Ad block Bool
Block ads in converting page.
Default: False Show all
Copy parameter's URL

CookieConsentBlock

Remove cookie warnings Bool
Tries to remove EU regulation required cookie warnings from web pages.
Default: False Show all
Copy parameter's URL

JavaScript

Enable JavaScript Bool
Allow web pages to run JavaScript.
Default: True Show all
Copy parameter's URL

WaitElement

Wait for DOM element String
Element selector string of the DOM element. Converter will wait for this element to appear in DOM before conversion begins.
Show all
Copy parameter's URL

UserJs

Execute JavaScript String
Execute provided JavaScript before conversion begins.
Show all
Copy parameter's URL

UserCss

Apply additional CSS String
Apply additional CSS before conversion begins.
Show all
Copy parameter's URL

HideElements

Hide DOM elements String
Element selector string of the DOM elements that needs to be hidden during conversion.
Show all
Copy parameter's URL

CssMediaType

CSS media type String
Use CSS media type in conversion process. The default screen and print media types are supported but not limited to these. The custom media type, like convertapi can be used too.
Default: screen Show all
Copy parameter's URL

LoadLazyContent

Load lazy content Bool
Load page images that loads only when they are visible.
Default: False Show all
Copy parameter's URL

ViewportWidth

Viewport width Integer
Sets browser viewport width.
Default: 1366 Range: 200 .. 4000 Show all
Copy parameter's URL

ViewportHeight

Viewport height Integer
Sets browser viewport height.
Default: 1024 Range: 200 .. 4000 Show all
Copy parameter's URL

Background

Background Bool
Convert web page background.
Default: True Show all
Copy parameter's URL

FixedElements

Fixed elements Collection
Change fixed elements CSS 'position' property to adapt page for conversion.
Default: fixed Values: fixed absolute relative hide Show all
Copy parameter's URL

ShowElements

Show DOM elements String
Element selector string of the DOM elements that should be visible during conversion. Other elements will be hidden.
Show all
Copy parameter's URL

AvoidBreakElements

Avoid page break inside DOM elements String
CSS selector for the elements that pages should not break.
Show all
Copy parameter's URL

BreakBeforeElements

Page break before DOM elements String
CSS selector for the elements that should apply page break before it.
Show all
Copy parameter's URL

BreakAfterElements

Page break after DOM elements String
CSS selector for the elements that should apply page break after it.
Show all
Copy parameter's URL

RespectViewport

Respect viewport Bool
If true, the converter will generate PDF as the content looks like in the browser. If is set to false, the converter acts like Chrome print to PDF function.
Default: True Show all
Copy parameter's URL

Scale

Scale Content Integer
Set web page scale value in percentage.
Default: 100 Range: 10 .. 200 Show all
Copy parameter's URL

PageOrientation

Page orientation Collection
PDF page orientation.
Default: portrait Values: portrait landscape Show all
Copy parameter's URL

PageSize

Page size Collection
PDF page size.
Default: letter Values: a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 b0 b1 b2 b3 b4 b5 letter legal ledger Show all
Copy parameter's URL

MarginTop

Margin top Integer
Set the page top margin in millimeters (mm).
Default: 10 Range: 0 .. 500 Show all
Copy parameter's URL

MarginRight

Margin right Integer
Set the page right margin in millimeters (mm).
Default: 10 Range: 0 .. 500 Show all
Copy parameter's URL

MarginBottom

Margin bottom Integer
Set the page bottom margin in millimeters (mm).
Default: 10 Range: 0 .. 500 Show all
Copy parameter's URL

MarginLeft

Margin left Integer
Set the page left margin in millimeters (mm).
Default: 10 Range: 0 .. 500 Show all
Copy parameter's URL

Header

Header HTML String

This property will insert an HTML header into each page. HTML tags containing the classes pageNumber, totalPages, title, and date will be filled in with the metadata relevant to each individual page. Inline CSS could be utilized to style the HTML provided.

<style>
    .right {
        float: right;
    }

    .left {
        float: left;
    }
</style>
<span class='left'>
    page number 
    <span class='pageNumber'></span>
</span>
<span class='right'>
    date 
    <span class='date'></span>
</span>
Show all
Copy parameter's URL

Footer

Footer HTML String

This property will insert an HTML footer into each page. HTML tags containing the classes pageNumber, totalPages, title, and date will be filled in with the metadata relevant to each individual page. Inline CSS could be utilized to style the HTML provided.

<style>
    .right {
        float: right;
    }

    .left {
        float: left;
    }
</style>
<span class='left'>
    page number 
    <span class='pageNumber'></span>
</span>
<span class='right'>
    date 
    <span class='date'></span>
</span>
Show all
Copy parameter's URL

PageWidth

Page width Integer
Custom page width in millimeters (mm). This option override PageSize option.
Range: 10 .. 30000 Show all
Copy parameter's URL

PageHeight

Page height Integer
Custom page height in millimeters (mm). This option override PageSize option.
Range: 10 .. 30000 Show all
Copy parameter's URL

CompressPDF

Compress PDF Bool
It tries to produce smaller output files but requires Adobe Reader 6, released in 2003 or newer, to view created PDF files.
Default: False Show all

Code snippet

// Code snippet is using the ConvertAPI JavaScript Client: https://github.com/ConvertAPI/convertapi-js

// Code snippet is using the ConvertAPI Node.js Client: https://github.com/ConvertAPI/convertapi-nodejs

// Code snippet is using the ConvertAPI PHP Client: https://github.com/ConvertAPI/convertapi-php

// Code snippet is using the ConvertAPI Java Client: https://github.com/ConvertAPI/convertapi-java

// Code snippet is using the ConvertAPI C# Client: https://github.com/ConvertAPI/convertapi-dotnet

# Code snippet is using the ConvertAPI Ruby Client: https://github.com/ConvertAPI/convertapi-ruby

# Code snippet is using the ConvertAPI Python Client: https://github.com/ConvertAPI/convertapi-python

// Code snippet is using the ConvertAPI Go Client: https://github.com/ConvertAPI/convertapi-go

REM Code snippet is using the command line utility program: https://github.com/ConvertAPI/convertapi-cli

<!-- For conversions with the multiple file result please refer to this example: https://repl.it/@ConvertAPI/HTML-Form-with-multiple-file-result -->

Try HTML to PDF API for free!