Skip to main content

Page Setup

The pageSetup object controls the physical layout of every page in your PDF. All properties are optional and fall back to sensible defaults when omitted.

Properties

PropertyTypeDefaultDescription
sizestring"A4"Named page size
orientationstring"portrait"Page orientation
marginsnumber[][36, 36, 36, 36]Margins in points: [top, right, bottom, left]
backgroundColorstring | string[]Page background. Single hex string for one color, array for per-page banding (cycles when fewer entries than pages).
borderTopstringTop page border — CSS shorthand "<width> <style> <color>" (e.g. "1pt solid #000", "none").
borderRightstringRight page border (CSS shorthand).
borderBottomstringBottom page border (CSS shorthand).
borderLeftstringLeft page border (CSS shorthand).

Page sizes

DocPayload supports all standard ISO and North American page sizes:

ISO A series

SizeDimensions (mm)
A0841 x 1189
A1594 x 841
A2420 x 594
A3297 x 420
A4210 x 297
A5148 x 210
A6105 x 148
A774 x 105
A852 x 74
A937 x 52
A1026 x 37

ISO B series

SizeDimensions (mm)
B1707 x 1000
B2500 x 707
B3353 x 500
B4250 x 353
B5176 x 250
B6125 x 176
B788 x 125
B862 x 88
B944 x 62
B1031 x 44

North American sizes

SizeDimensions (in)
LETTER8.5 x 11
LEGAL8.5 x 14
TABLOID11 x 17
LEDGER17 x 11
EXECUTIVE7.25 x 10.5

Default

Use DEFAULT to inherit the system default, which is equivalent to A4.

Orientation

ValueDescription
portraitTaller than wide (default)
landscapeWider than tall

When landscape is set, the page dimensions are swapped. For example, A4 landscape produces a 297 x 210 mm page.

Margins

Margins are specified as a four-element array in points (1 point = 1/72 inch):

[top, right, bottom, left]

For reference:

  • 72 points = 1 inch = 25.4 mm
  • 50 points is approximately 17.6 mm or 0.69 inches

Examples

A4 portrait with default margins

{
"document": {
"pageSetup": {
"size": "A4",
"orientation": "portrait",
"margins": [50, 40, 50, 40]
},
"content": [
{ "p": "Standard A4 document." }
]
}
}

US Letter landscape with wide margins

{
"document": {
"pageSetup": {
"size": "LETTER",
"orientation": "landscape",
"margins": [72, 72, 72, 72]
},
"content": [
{ "p": "Landscape letter with 1-inch margins on all sides." }
]
}
}
{
"document": {
"pageSetup": {
"size": "LEGAL",
"orientation": "portrait",
"margins": [60, 30, 60, 30]
},
"content": [
{ "p": "Legal-size document with narrow side margins for maximum content width." }
]
}
}

Tabloid for large-format reports

{
"document": {
"pageSetup": {
"size": "TABLOID",
"orientation": "portrait",
"margins": [50, 50, 50, 50]
},
"content": [
{ "p": "Tabloid-size document for large charts and diagrams." }
]
}
}

Page background colors

Apply different background colors to successive pages. Colors cycle if there are more pages than entries.

{
"document": {
"pageSetup": {
"size": "A4",
"margins": [
50,
40,
50,
40
],
"backgroundColor": [
"#FAFAFA",
"#F0F4FF"
]
},
"content": [
{
"p": "Page 1 has a light gray background."
},
{
"break": "page"
},
{
"p": "Page 2 has a light blue background."
},
{
"break": "page"
},
{
"p": "Page 3 cycles back to light gray."
}
]
}
}
note

backgroundColor currently renders on top of content in some configurations. Use light, subtle colors and test your output to ensure readability.

Page borders

Add border rules to every page. Each side is its own property — borderTop, borderRight, borderBottom, borderLeft — using the CSS shorthand "<width> <style> <color>". Components are independently optional and can appear in any order; "none" removes the side. Sides are independent: setting borderTop doesn't reset the others.

{
"document": {
"pageSetup": {
"size": "A4",
"margins": [50, 40, 50, 40],
"borderTop": "0.5pt solid #CCCCCC",
"borderBottom": "0.5pt solid #CCCCCC"
},
"content": [
{ "p": "This document has thin gray rules at the top and bottom of every page." }
]
}
}

Combine all four sides for a full page frame:

"pageSetup": {
"borderTop": "1pt solid #1A1A2E",
"borderRight": "1pt solid #1A1A2E",
"borderBottom": "1pt solid #1A1A2E",
"borderLeft": "1pt solid #1A1A2E"
}

Per-section overrides

The pageSetup at the document root is the default for every page. To change page setup partway through — a landscape appendix, a different page size for an insert, narrower margins for a chapter — partition the document with a section break that carries its own inline pageSetup.

{
"document": {
"pageSetup": {
"size": "LETTER",
"orientation": "portrait",
"margins": [50, 50, 50, 50]
},
"content": [
{ "h1": "Main body" },
{ "p": "Renders with the document-root pageSetup (LETTER portrait)." },

{ "break": "section",
"pageSetup": {
"size": "TABLOID",
"orientation": "landscape",
"margins": [30, 30, 30, 30],
"backgroundColor": "#FAFAFA"
}
},

{ "h1": "Appendix" },
{ "p": "Renders TABLOID landscape with the appendix pageSetup applied to every page in this section." }
]
}
}

The inline pageSetup on the break accepts every key the document-root pageSetup does — size, orientation, margins, backgroundColor, borderTop/borderRight/borderBottom/borderLeft. Each property is independent: omit a key to inherit it from the document root. The break also accepts inline header / footer for per-section chrome (see Headers & Footers).

pageSetup is for page-level configuration only — it does not accept content-formatting keys like fontSize or fontColor. Those belong in styles and apply to text elements, not pages.

A section break starts a new page when the resolved page setup differs from the previous section's. Sections sharing identical setup may render on the same physical page.