Skip to main content

PDF Params

PDF Params options

Here’s a list of all the optional parameters that you can send as an object “pdfParams” while using our HTML to PDF endpoint:
Whether to show the header and footer. Default: false
headerTemplate
string
HTML template for the header. See valid HTML markup bellow.
HTML template for the footer. See valid HTML markup bellow.
printBackground
boolean
Set to true to print background graphics. Default: false
landscape
boolean
Whether to print in landscape orientation. Default: false
format
PaperFormat
All the valid paper format types when printing a PDF. See all format options here. Default: Letter
width
string | number
Paper width, accepts values labeled with units.
height
string | number
Paper height, accepts values labeled with units.
margin
object
Object that sets the margin of every page. See all margin options here.
preferCSSPageSize
boolean
Give any CSS @page size declared in the page priority over what is declared in the width or height or format option. Default: false
outline
boolean
Whether or not to embed the document outline into the PDF. Default: false
The width, height, and margin options accept values labeled with units. Unlabeled values are treated as pixels.All possible formats:
  • width: 100 (prints with width set to 100 pixels)
  • width: ‘100px’ (prints with width set to 100 pixels)
  • width: ‘100in’ (prints with width set to 100 inches)
  • width: ‘100cm,’ (prints with width set to 100 centimeters)
  • width: ‘100mm’ (prints with width set to 100 millimeters)

Header and Footer: Valid HTML Markups

HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them:
  • 'date' formatted print date
  • 'title' document title
  • 'url' document location
  • 'pageNumber' current page number
  • 'totalPages' total pages in the document
Example:
<style>
  #header {
    display: none;
  }
  #footer {
    padding: 0 !important;
    margin: 0 !important;
  }
</style>
<div
  style="font-family: inherit; font-size: 12px; color: #64748b; padding: 5px 20px; margin-top: 20px; width: 100%;"
>
  <span>Some custom footer text here</span>
  <div
    style="display: flex; flex-direction: row; gap: 20px; align-items: center; font-size: inherit; color: inherit; justify-content: space-between;"
  >
    <span class="title"></span>
    <p>|</p>
    <span class="date"></span>
    <p style="margin-left: auto;">
      Page <span class="pageNumber"></span> of <span class="totalPages"></span>
    </p>
  </div>
</div>

Paper format options

Format nameSize in inchesSize in cm
Letter8.5in x 11in21.6cm x 27.9cm
Legal8.5in x 14in21.6cm x 35.6cm
Tabloid11in x 17in27.9cm x 43.2cm
Ledger17in x 11in43.2cm x 27.9cm
A033.1in x 46.8in84cm x 118.9cm
A123.4in x 33.1in59.4cm x 84cm
A216.54in x 23.4in42cm x 59.4cm
A311.7in x 16.54in29.7cm x 42cm
A48.27in x 11.7in21cm x 29.7cm
A55.83in x 8.27in14.8cm x 21cm
A64.13in x 5.83in10.5cm x 14.8cm

Margin Options

margin.top
string | number
Top margin, accepts values labeled with units. Default: 0
margin.right
string | number
Right margin, accepts values labeled with units. Default: 0
margin.left
string | number
Left margin, accepts values labeled with units. Default: 0
margin.bottom
string | number
Bottom margin, accepts values labeled with units. Default: 0
  • Example:
{
  "margin": {
    "top": 10,
    "right": "10px",
    "bottom": "10in",
    "left": "10cm"
  }
}