Build pages

The page element defines settings that apply to the entire template. It defines the page size and margins, header and footer behavior, and default HTML styles that apply to all elements in the template unless you otherwise define them for specific elements. Page does not contain content elements that appear on invoices.

Note: You can create more than one active version of an invoice template per locale, and use conditional expressions to determine which fields appear on a version of an invoice template. You can only use conditional expressions in templates that you create or that you copy from a marketplace-provided default template. You cannot add conditional expressions to marketplace default templates. For more information, see Build pages.

Prerequisites

None.

Default template JSON sample

In the Appdirect Template_EN_US default template, see lines 143-189.

To download the default template, go to .

JSON structure context for page

Page exists at the same level as the three invoice sections, header, body, and footer.

{
    "page": {},
    "header": {},
    "body": {},
    "footer": {}
}

Page settings JSON schema

{
  "page": {
    "pageStyle": {
      "pageMargin": {
        "top": "45px",
        "right": "45px",
        "bottom": "45px",
        "left": "45px"
      }
    },
    "properties": {
      "format": "A4",
      "height": "11in",
      "width": "8.5in",
      "displayHeaderOnFirstPage": false,
      "displayFooterOnFirstPage": true
    },
    "elementStyles": [
      {
        "name": "p",
        "style": {
          "font-size": "9px"
        }
      }
    ]
  }

Elements to build page section

Element       Type Description

page

      object

Required. Defines page properties.

  pageStyle   object Required. Defines page default styles.
    pageMargin   object

Defines PDF page margin widths.

      top string

Top margin width in pixels, ems, millimeters, points, or inches.

Format: 

[0-9]+(px|em|mm|pt|in)

Valid values: Dimension.

Example:

45px
      right string

Right margin width in pixels, ems, millimeters, points, or inches.

Format: 

[0-9]+(px|em|mm|pt|in)

Valid values: Dimension.

Example:

45px
      bottom string

Bottom margin width in pixels, ems, millimeters, points, or inches.

Format: 

[0-9]+(px|em|mm|pt|in)

Valid values: Dimension.

Example:

45px
      left string

Left margin width in pixels, ems, millimeters, points, or inches.

Format: 

[0-9]+(px|em|mm|pt|in)

Valid values: Dimension.

Example:

45px
 

properties

    object Required. Define page dimensions, and header and footer behaviour. Optionally, add properties that define visibility.
    format   string

Required. Page dimensions defined by paper format name. When format is defined, it overrides height and width properties. When null, height and width properties override this property.

A4 | Letter | null

A4 dimensions: 8.27 × 11.69 inches. Letter dimensions: 8.5 by 11 inches.

    height   string

Required. Page height dimension in pixels, ems, millimeters, points, or inches.

When format property is defined, it overrides this property. To define custom dimensions, populate this and the width property, and set the format property to null.

Format:

[0-9]+(px|em|mm|pt|in)

Valid values: Dimension or null.

Example:

11in
    width   string

Required. Page width dimension in pixels, ems, millimeters, points, or inches.

When format property is defined, it overrides this property. To define custom dimensions, populate this and the width property, and define the format property as null.

Format:

[0-9]+(px|em|mm|pt|in)

Valid values: Dimension or null.

Example:

11in
    displayHeaderOnFirstPage boolean

Required. When a first or default header is defined in the header (see Build headers) and this property is set to true, a header appears on the first page; when set to false, a header does not appear on first page.

Valid Values:

true | false
    displayFooterOnFirstPage boolean

Required. When footer is defined in the footer component (see Build footers) and when this property is set to true, the footer appears on all pages; when set to false, the footer does not appear on any pages.

true | false
  elementStyles   array Style settings that apply to all elements in the template. Styles otherwise defined override these defaults.
    name   string

HTML element name for which a style is defined.

Valid values: All HTML element names.

Examples: 

a
p
table th
    style   object

Defines CSS styles for the named HTML element. Only relevant styles that the Invoice Builder can render appear in the user interface preview and the PDF.

Examples for "a":

"color": #474747"
"text-decoration": "none"

 

Examples for "p":

"font-size": "9px"
"font-family": "Arial"

 

Example for "table th":

"font-family": "Arial"