pdforge
API Reference
API Reference
  • Getting started
    • Overview
    • Authentication
    • Rate limit
  • PDFs from templates
    • Asynchronous request
    • Synchronous request
  • Html to pdf conversion
    • Asynchronous request
    • Synchronous request
  • OPTIONS
    • How render PNG instead of PDF
    • Storage Options (s3)
    • PDF Params
Powered by GitBook
On this page
  • PDF Params options
  • Header and Footer: Valid HTML Markups
  • Paper format options
  • Margin Options
  1. OPTIONS

PDF Params

When using our HTML to PDF endpoint, you can send a whole list of parameters to help you better tailor your PDF layout.

When using reusable templates, these parameters are set on the interface, so you don't need send any extra parameters on the API.

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:

Property name
Type
Description

displayHeaderFooter

boolean

Whether to show the header and footer. default: false

headerTemplate

string

footerTemplate

string

printBackground

boolean

Set to true to print background graphics. default: false

landscape

boolean

Whether to print in landscape orientation. default: false

format

PaperFormat

width

string | number

Paper width, accepts values labeled with units.

height

string | number

Paper height, accepts values labeled with units.

margin

Margin (object)

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 name
Size in inches
Size in cm

Letter

8.5in x 11in

21.6cm x 27.9cm

Legal

8.5in x 14in

21.6cm x 35.6cm

Tabloid

11in x 17in

27.9cm x 43.2cm

Ledger

17in x 11in

43.2cm x 27.9cm

A0

33.1in x 46.8in

84cm x 118.9cm

A1

23.4in x 33.1in

59.4cm x 84cm

A2

16.54in x 23.4in

42cm x 59.4cm

A3

11.7in x 16.54in

29.7cm x 42cm

A4

8.27in x 11.7in

21cm x 29.7cm

A5

5.83in x 8.27in

14.8cm x 21cm

A6

4.13in x 5.83in

10.5cm x 14.8cm


Margin Options

Property name
Type
Description

top

string | number

Top margin, accepts values labeled with units. default: 0

right

string | number

Right margin, accepts values labeled with units. default: 0

left

string | number

Left margin, accepts values labeled with units. default: 0

bottom

string | number

Bottom margin, accepts values labeled with units. default: 0

  • Example:

{
    "margin": {
        "top": 10,
        "right": "10px", 
        "bottom": "10in", 
        "left": "10cm"
    }
}
PreviousStorage Options (s3)

Last updated 14 days ago

HTML template for the header. .

HTML template for the footer. .

All the valid paper format types when printing a PDF. . default: Letter

Object that sets the margin of every page. .

See valid HTML markup bellow
See valid HTML markup bellow
See all format options here
See all margin options here