PDF Theme Files (`theme.json`)
A theme controls the entire visual appearance of a PDF produced by PowerDocs: heading colours, fonts, table styling, page format and margins, and the layout of the cover page.
A theme is a plain JSON file. It contains no code, no expressions and no scripting — it is a declarative document you version alongside your Markdown sources so that a build on a CI/CD runner produces exactly the same PDF as a build on a developer workstation.
Applying a Theme
There are two ways to select a theme, and they can be combined.
1. From the command line
# Built-in theme, by name
powerdocs-cli plan.yml export.pdf --theme corporate-classic
# Custom theme file, by path
powerdocs-cli plan.yml export.pdf --theme ./branding/theme.json
2. From the document plan
Add a Theme key at the root of your .yml document plan:
Title: "Technical Specification"
Company: "Contoso Ltd."
Author: "Jane Doe"
CurrentVersion: "2.4.0"
Theme: "./branding/theme.json"
Items:
- ItemType: CoverPage
- ItemType: Summary
- ItemType: File
ItemPath: "chapters/01-introduction.md"
Precedence: the
--themecommand-line option always wins over theThemekey of the plan. If neither is present, the default theme is used.
Path resolution
The value of --theme / Theme is resolved in this order:
- If it is an absolute path to an existing file, that file is loaded.
- If it is a relative path, it is resolved against the document plan's directory, then against the current working directory.
- If no file matches, the value is looked up as a built-in theme name.
- If nothing matches, a warning is printed on
stderrand the default theme is used. Generation is not aborted.
Built-in themes
These names can be passed directly, with no file to author:
| Name | Description |
|---|---|
default |
The historical PowerDocs look: blue headings on grey body text. |
corporate-classic |
Navy blue and gold. Institutional documents. |
minimal |
Greyscale only, no colour accent, no table zebra striping. |
midnight |
Deep indigo with a lavender accent. Modern and high contrast. |
slate |
Slate grey with a sky-blue accent. Neutral and professional. |
emerald |
Emerald green. Suited to finance, CSR and environmental topics. |
sunset |
Burnt orange and amber. Warm, for creative or marketing documents. |
burgundy |
Deep burgundy red. Legal and institutional documents. |
A built-in theme is also the best starting point for a custom one: copy the JSON of the closest match and change only what you need.
File Structure
A theme file has five top-level sections. Every section and every property is optional — anything you omit falls back to the default theme's value, so a minimal theme is perfectly valid.
{
"name": "my-theme",
"typography": {},
"palette": {},
"table": {},
"page": {},
"coverPage": {}
}
| Section | Purpose |
|---|---|
name |
Display name of the theme. Informational only. |
typography |
Font families, heading sizes, body size, embedded font files. |
palette |
Colours for headings, text, links, code blocks and quotes. |
table |
Header, border and zebra-striping colours for tables. |
page |
Page format and margins. |
coverPage |
Optional declarative cover page layout. Omit it to keep the default cover. |
The smallest useful theme
Overriding just three colours is enough for most corporate branding needs:
{
"name": "acme",
"palette": {
"headingColor": "#8A1538",
"titleColor": "#8A1538",
"accentColor": "#D4A017"
},
"table": {
"headerBackground": "#8A1538"
}
}
Colour Values
Every colour property in a theme accepts the following formats:
| Format | Example | Notes |
|---|---|---|
#RRGGBB |
"#1976D2" |
The recommended form. |
#RGB |
"#1AF" |
Shorthand, expanded to #11AAFF. |
#AARRGGBB |
"#801976D2" |
With an alpha channel, alpha first. |
| Named colour | "blue" |
See the list below. |
Recognised names: red, green, blue, orange, grey / gray, white, black, amber, emerald, teal,
cyan, indigo, purple.
The leading # is optional. An unparseable value silently falls back to that property's built-in default colour, so a
typo produces a document with a wrong colour rather than a failed build — check your output if a colour does not appear.
typography
{
"typography": {
"headingFontFamily": "Montserrat",
"bodyFontFamily": "Source Sans Pro",
"codeFontFamily": "JetBrains Mono",
"headingSizes": [
28,
22,
18,
15,
13,
11
],
"bodyFontSize": 11,
"embeddedFonts": [
{
"family": "Montserrat",
"file": "fonts/Montserrat-Regular.ttf"
},
{
"family": "Source Sans Pro",
"file": "fonts/SourceSansPro-Regular.ttf"
},
{
"family": "JetBrains Mono",
"file": "fonts/JetBrainsMono-Regular.ttf"
}
]
}
}
| Property | Type | Default | Description |
|---|---|---|---|
headingFontFamily |
string | null |
null |
Font for headings H1–H6. null keeps the PDF engine's default font. |
bodyFontFamily |
string | null |
null |
Font for body text. null keeps the engine default. |
codeFontFamily |
string | "Consolas" |
Monospaced font for code blocks. |
headingSizes |
number[] | [24, 20, 16, 14, 12, 11] |
Sizes in points, indexed by heading level: index 0 is H1, index 5 is H6. |
bodyFontSize |
number | 11 |
Default body text size, in points. |
embeddedFonts |
object[] | [] |
Font files to load and register under an explicit family name. |
Heading sizes
headingSizes is positional. A level with no matching entry falls back to 11 pt, so always supply six values if you
customise this array:
"headingSizes": [
28,
22,
18,
15,
13,
11
]
Read positionally, that is H1 = 28 pt, H2 = 22 pt, H3 = 18 pt, H4 = 15 pt, H5 = 13 pt, H6 = 11 pt.
Embedded fonts
By default, a font family name must be installed on the machine running the generation. That makes the output dependent on the host — a CI/CD runner or a container rarely has the same fonts installed as a designer's workstation.
embeddedFonts removes that dependency: each entry loads a .ttf or .otf file from disk and registers it under the
family name you choose, which you then reference from headingFontFamily, bodyFontFamily or codeFontFamily.
"embeddedFonts": [
{
"family": "Montserrat",
"file": "fonts/Montserrat-Regular.ttf"
}
]
| Property | Description |
|---|---|
family |
The name to register the font under. Use this exact string in the *FontFamily properties. |
file |
Path to the font file. Relative paths resolve against the theme file's own directory, not the plan or the working directory. |
A recommended layout, fully self-contained and portable:
branding/
├── theme.json
├── assets/
│ └── logo.png
└── fonts/
├── Montserrat-Regular.ttf
└── SourceSansPro-Regular.ttf
A missing font file produces a warning on
stderrand is skipped — the generation continues with the engine's fallback font. If your PDF comes out in the wrong typeface, checkstderrfirst.
palette
{
"palette": {
"headingColor": "#1976D2",
"titleColor": "#1565C0",
"accentColor": "#2196F3",
"textColor": "#424242",
"mutedColor": "#9E9E9E",
"linkColor": "#2196F3",
"codeBackground": "#F5F5F5",
"codeBorder": "#E0E0E0",
"quoteBorder": "#9E9E9E"
}
}
| Property | Default | Applies to |
|---|---|---|
headingColor |
#1976D2 |
Markdown headings H1–H6, and the "Summary" / "Change history" section titles. |
titleColor |
#1565C0 |
The cover page main title, chapter titles, and top-level summary entries. |
accentColor |
#2196F3 |
Decorative separator rules on the cover page and chapter pages. |
textColor |
#424242 |
Body text. |
mutedColor |
#9E9E9E |
Secondary text: dates, subtitles, discreet mentions. |
linkColor |
#2196F3 |
Markdown hyperlinks. |
codeBackground |
#F5F5F5 |
Background of code blocks and of custom container boxes. |
codeBorder |
#E0E0E0 |
Border of code blocks, tables and container boxes, plus the Markdown --- horizontal rule. |
quoteBorder |
#9E9E9E |
Left border of blockquotes (>). |
Note that codeBorder is used well beyond code blocks — it is the general-purpose "light rule" colour of the document.
table
Applies both to Markdown tables and to the generated change-history table.
{
"table": {
"headerBackground": "#1976D2",
"headerTextColor": "#FFFFFF",
"borderColor": "#E0E0E0",
"zebraStripeColor": "#FAFAFA"
}
}
| Property | Type | Default | Description |
|---|---|---|---|
headerBackground |
string | #1976D2 |
Background of the header row. |
headerTextColor |
string | #FFFFFF |
Text colour of the header row. |
borderColor |
string | #E0E0E0 |
Cell borders. |
zebraStripeColor |
string | null |
#FAFAFA |
Background of even body rows. Set to null to disable zebra striping entirely. |
To get flat tables with no alternating row shading:
"table": {
"headerBackground": "#212121",
"zebraStripeColor": null
}
page
{
"page": {
"size": "A4",
"marginCm": 1.2,
"coverMarginCm": 1.5
}
}
| Property | Type | Default | Description |
|---|---|---|---|
size |
string | "A4" |
Page format. |
marginCm |
number | 1.2 |
Margin of content pages, in centimetres. |
coverMarginCm |
number | 1.5 |
Margin of the cover page, in centimetres. |
Accepted size values (case-insensitive): A3, A4, A5, Letter, Legal, Tabloid, Executive. An unrecognised
value falls back to A4.
US Letter with wider margins:
"page": {
"size": "Letter",
"marginCm": 2.0,
"coverMarginCm": 2.5
}
Page margins are in centimetres. Everything else in a theme — font sizes, cover page dimensions, paddings — is in PDF points (1 pt = 1/72 inch).
coverPage
Omit this section and PowerDocs renders its default cover page, themed with your palette: centred title, an accent rule, then company, author, version and the current date.
Supply it and you replace that layout entirely with your own tree of blocks.
{
"coverPage": {
"root": {
"type": "column",
"children": []
}
}
}
The root node is the top of the tree. If coverPage is present but root is absent, the default layout is used.
Node types
Every node has a type. Any unrecognised value — including an omitted one — is treated as column.
type |
Description |
|---|---|
column |
Vertical stack. Renders its children top to bottom. The default. |
row |
Horizontal band. Splits the available width equally among its children. |
text |
A line of text, either literal or bound to a document plan field. |
line |
A horizontal separator rule. |
image |
An image loaded from disk. |
spacer |
Empty vertical space. |
Node properties
| Property | Type | Default | Applies to | Description |
|---|---|---|---|---|
type |
string | "column" |
all | The node type. |
children |
node[] | [] |
column, row |
Child nodes. |
bind |
string | — | text |
Binds the text to a plan field. See below. |
text |
string | — | text |
Literal text. Also used as a fallback when bind resolves to an empty field. |
fontSize |
number | 12 |
text, line |
Font size for text; fallback thickness for line when height is absent. |
bold |
bool | false |
text |
Bold. |
italic |
bool | false |
text |
Italic. |
color |
string | — | text, line |
A colour value, or a theme token (see below). |
align |
string | "Center" |
all | "Left", "Center" or "Right". |
width |
number | — | line, image |
Fixed width in points. Omit to take the full available width. |
height |
number | — | spacer, line |
Height of the blank space, or thickness of the rule, in points. |
src |
string | — | image |
Image path, relative to the theme file's directory. |
paddingTop |
number | 0 |
all | Extra space above the node, in points. |
paddingBottom |
number | 0 |
all | Extra space below the node, in points. |
Binding text to the document plan
A text node with a bind property pulls its content from the document plan instead of the theme, which is what makes
a cover page reusable across documents.
bind value |
Resolves to | Notes |
|---|---|---|
title |
Title |
Falls back to text, then to "Document". |
author |
Author |
Falls back to text. |
company |
Company |
Falls back to text. |
version |
CurrentVersion |
Rendered as "Version 2.4.0" — the Version prefix is added for you. Falls back to text. |
date |
Today's date | Formatted dd MMMM yyyy, e.g. 20 September 2026. Ignores text. |
classification |
Classification |
Falls back to text. |
An unrecognised bind value falls back to text. A text node that resolves to an empty string renders nothing at
all — including its padding — so optional fields collapse cleanly rather than leaving gaps.
This node uses the plan's company name, falling back to a hard-coded default when the plan has none:
{
"type": "text",
"bind": "company",
"text": "Contoso Ltd.",
"fontSize": 18,
"color": "@text"
}
Theme colour tokens
Inside a cover page node, color also accepts a @token that points back at your palette. Prefer tokens over literal
hex values: the cover page then follows the palette automatically when you re-skin the theme.
| Token | Palette property |
|---|---|
@heading |
palette.headingColor |
@title |
palette.titleColor |
@accent |
palette.accentColor |
@text |
palette.textColor |
@muted |
palette.mutedColor |
@link |
palette.linkColor |
An unknown token falls back to the node's built-in default colour.
Example: logo, title and a two-column footer
{
"coverPage": {
"root": {
"type": "column",
"children": [
{
"type": "image",
"src": "assets/logo.png",
"width": 140,
"align": "Center",
"paddingBottom": 30
},
{
"type": "text",
"bind": "title",
"fontSize": 34,
"bold": true,
"color": "@title",
"align": "Center"
},
{
"type": "line",
"width": 180,
"height": 3,
"color": "@accent",
"align": "Center",
"paddingTop": 16,
"paddingBottom": 24
},
{
"type": "text",
"bind": "classification",
"fontSize": 10,
"bold": true,
"color": "@accent",
"align": "Center",
"paddingBottom": 8
},
{
"type": "spacer",
"height": 60
},
{
"type": "row",
"children": [
{
"type": "text",
"bind": "author",
"fontSize": 12,
"color": "@text",
"align": "Left"
},
{
"type": "text",
"bind": "date",
"fontSize": 12,
"italic": true,
"color": "@muted",
"align": "Right"
}
]
},
{
"type": "text",
"bind": "version",
"fontSize": 13,
"bold": true,
"color": "@heading",
"align": "Center",
"paddingTop": 20
}
]
}
}
}
A few things worth noting in that example:
- The
rowgives each of its two children half the page width, which is whyalign: "Left"andalign: "Right"push the author and the date to opposite edges. - The
spacerpushes the footer block down by 60 pt without needing an empty text node. classificationdisappears entirely if the plan has noClassificationkey, and the layout closes up around it.- Every colour is a token, so restyling the whole document — cover page included — means editing the
palettesection only.
Images
src is resolved relative to the theme file's directory. Keep your assets next to theme.json and your branding
folder stays portable across machines and repositories.
An image whose file cannot be found is silently skipped, with no warning and no placeholder. If your logo is missing from the output, check the path first.
Images are scaled to fit their width. Set width to constrain them; without it, the image spans the full content width
of the cover page.
Complete Example
A full, self-contained corporate theme with embedded fonts and a custom cover page:
{
"name": "acme-corporate",
"typography": {
"headingFontFamily": "Montserrat",
"bodyFontFamily": "Source Sans Pro",
"codeFontFamily": "JetBrains Mono",
"headingSizes": [
28,
22,
18,
15,
13,
11
],
"bodyFontSize": 10.5,
"embeddedFonts": [
{
"family": "Montserrat",
"file": "fonts/Montserrat-SemiBold.ttf"
},
{
"family": "Source Sans Pro",
"file": "fonts/SourceSansPro-Regular.ttf"
},
{
"family": "JetBrains Mono",
"file": "fonts/JetBrainsMono-Regular.ttf"
}
]
},
"palette": {
"headingColor": "#8A1538",
"titleColor": "#6B1029",
"accentColor": "#D4A017",
"textColor": "#333333",
"mutedColor": "#8C8C8C",
"linkColor": "#8A1538",
"codeBackground": "#FAF7F8",
"codeBorder": "#E4DCDE",
"quoteBorder": "#D4A017"
},
"table": {
"headerBackground": "#8A1538",
"headerTextColor": "#FFFFFF",
"borderColor": "#E4DCDE",
"zebraStripeColor": "#FAF7F8"
},
"page": {
"size": "A4",
"marginCm": 1.5,
"coverMarginCm": 2.0
},
"coverPage": {
"root": {
"type": "column",
"children": [
{
"type": "image",
"src": "assets/acme-logo.png",
"width": 130,
"align": "Center",
"paddingBottom": 36
},
{
"type": "text",
"bind": "title",
"fontSize": 32,
"bold": true,
"color": "@title",
"align": "Center"
},
{
"type": "line",
"width": 200,
"height": 2,
"color": "@accent",
"align": "Center",
"paddingTop": 18,
"paddingBottom": 28
},
{
"type": "text",
"bind": "company",
"fontSize": 16,
"color": "@text",
"align": "Center",
"paddingBottom": 10
},
{
"type": "text",
"bind": "author",
"fontSize": 13,
"color": "@muted",
"align": "Center"
},
{
"type": "spacer",
"height": 80
},
{
"type": "text",
"bind": "version",
"fontSize": 13,
"bold": true,
"color": "@heading",
"align": "Center",
"paddingBottom": 6
},
{
"type": "text",
"bind": "date",
"fontSize": 11,
"italic": true,
"color": "@muted",
"align": "Center"
}
]
}
}
}
Matching plan:
Title: "Platform Architecture"
Company: "ACME Corporation"
Author: "Engineering Team"
CurrentVersion: "3.1.0"
Classification: "Internal"
Theme: "branding/theme.json"
Items:
- ItemType: CoverPage
- ItemType: Summary
- ItemType: ChangeLog
- ItemType: Chapter
ItemTitle: "Overview"
- ItemType: File
ItemPath: "chapters/overview.md"
Troubleshooting
Theme handling is deliberately non-fatal: a broken theme degrades the look of the document but never fails the build.
That means problems surface as a wrong-looking PDF rather than a non-zero exit code — so read stderr.
| Symptom | Likely cause |
|---|---|
| Document renders with the default blue look | The theme was not found. A warning is printed on stderr: check the path, and remember that relative paths resolve against the plan's directory. |
| Fonts are wrong or generic | The font family is not installed on the host, or the embeddedFonts file path is wrong. A warning on stderr names the file it could not load. |
| Cover page logo is missing | Bad src path. This failure is silent — no warning is printed. Paths resolve against the theme file's directory. |
| A colour is ignored | Unparseable colour value, silently replaced by the default. Check for a typo in the hex code or an unsupported colour name. |
| A cover page field does not appear | The bound plan field is empty and no text fallback was provided. |
| H5/H6 headings are all the same size | headingSizes has fewer than six entries. Missing levels fall back to 11 pt. |
| Page size ignored | Unrecognised page.size, silently replaced by A4. |
Checklist for a portable theme
- Keep
theme.json,fonts/andassets/in one directory, committed to the repository. - Reference fonts and images with relative paths only.
- Use
embeddedFontsrather than relying on system-installed fonts, so CI/CD runners and containers render identically. - Use
@tokencolours in the cover page instead of literal hex values. - Run one generation and inspect
stderrbefore trusting a new theme in a pipeline.