Layout
12-column grid, fixed-height rows, lines, spacers, page sizes, and margins
Grid Layout
The 12-column grid system supports full-width, multi-column, and asymmetric layouts.
::pdf-example{pdf="/pdfs/examples/03_grid_layout.pdf"}
{
"page": {"size": "A4", "margins": "15mm"},
"body": [
{"row": {"cols": [
{"span": 12, "elements": [
{"type": "text", "content": "12-Column Grid Layout", "style": {"size": 18, "bold": true}},
{"type": "spacer", "height": "5mm"}
]}
]}},
{"row": {"cols": [
{"span": 12, "text": "Col 12 (full width)", "style": {"background": "#E3F2FD"}}
]}},
{"row": {"cols": [
{"span": 12, "spacer": "3mm"}
]}},
{"row": {"cols": [
{"span": 6, "text": "Col 6 (left)", "style": {"background": "#E8F5E9"}},
{"span": 6, "text": "Col 6 (right)", "style": {"background": "#FFF3E0"}}
]}},
{"row": {"cols": [
{"span": 12, "spacer": "3mm"}
]}},
{"row": {"cols": [
{"span": 4, "text": "Col 4", "style": {"background": "#FCE4EC"}},
{"span": 4, "text": "Col 4", "style": {"background": "#F3E5F5"}},
{"span": 4, "text": "Col 4", "style": {"background": "#E8EAF6"}}
]}},
{"row": {"cols": [
{"span": 12, "spacer": "3mm"}
]}},
{"row": {"cols": [
{"span": 3, "text": "Col 3", "style": {"background": "#E0F7FA"}},
{"span": 3, "text": "Col 3", "style": {"background": "#E0F2F1"}},
{"span": 3, "text": "Col 3", "style": {"background": "#FFF9C4"}},
{"span": 3, "text": "Col 3", "style": {"background": "#FFECB3"}}
]}},
{"row": {"cols": [
{"span": 12, "spacer": "3mm"}
]}},
{"row": {"cols": [
{"span": 3, "text": "Sidebar (3)", "style": {"background": "#D7CCC8"}},
{"span": 9, "text": "Main content (9)", "style": {"background": "#F5F5F5"}}
]}},
{"row": {"cols": [
{"span": 12, "spacer": "3mm"}
]}},
{"row": {"cols": [
{"span": 8, "text": "Article area (8)", "style": {"background": "#E1F5FE"}},
{"span": 4, "text": "Side panel (4)", "style": {"background": "#FBE9E7"}}
]}},
{"row": {"cols": [
{"span": 12, "spacer": "3mm"}
]}},
{"row": {"cols": [
{"span": 6, "elements": [
{"type": "text", "content": "Left column - line 1"},
{"type": "text", "content": "Left column - line 2"},
{"type": "text", "content": "Left column - line 3"}
]},
{"span": 6, "elements": [
{"type": "text", "content": "Right column - line 1"},
{"type": "text", "content": "Right column - line 2"},
{"type": "text", "content": "Right column - line 3"}
]}
]}}
]
}
::
Fixed-Height Rows
Use Row() with an explicit height instead of AutoRow() for fixed-height rows.
::pdf-example{pdf="/pdfs/examples/04_fixed_height_row.pdf"}
{
"page": {"size": "A4", "margins": "20mm"},
"body": [
{"row": {"cols": [
{"span": 12, "elements": [
{"type": "text", "content": "Fixed-Height Row Examples", "style": {"size": 18, "bold": true}},
{"type": "spacer", "height": "5mm"}
]}
]}},
{"row": {"height": "30mm", "cols": [
{"span": 12, "text": "This row is 30mm tall", "style": {"background": "#E3F2FD"}}
]}},
{"row": {"cols": [
{"span": 12, "spacer": "3mm"}
]}},
{"row": {"height": "50mm", "cols": [
{"span": 6, "text": "Left: 50mm row", "style": {"background": "#E8F5E9"}},
{"span": 6, "text": "Right: 50mm row", "style": {"background": "#FFF3E0"}}
]}},
{"row": {"cols": [
{"span": 12, "spacer": "3mm"}
]}},
{"row": {"cols": [
{"span": 12, "text": "This row has auto height (fits content)", "style": {"background": "#FCE4EC"}}
]}}
]
}
::
Lines
Horizontal rules with customizable color and thickness.
::pdf-example{pdf="/pdfs/examples/05_line.pdf"}
{
"page": {"size": "A4", "margins": "20mm"},
"body": [
{"row": {"cols": [
{"span": 12, "elements": [
{"type": "text", "content": "Line / Horizontal Rule Examples", "style": {"size": 18, "bold": true}},
{"type": "spacer", "height": "5mm"}
]}
]}},
{"row": {"cols": [
{"span": 12, "elements": [
{"type": "text", "content": "Default line (gray, 1pt):"},
{"type": "line"},
{"type": "spacer", "height": "5mm"}
]}
]}},
{"row": {"cols": [
{"span": 12, "elements": [
{"type": "text", "content": "Red line:"},
{"type": "line", "line": {"color": "red"}},
{"type": "spacer", "height": "3mm"},
{"type": "text", "content": "Blue line:"},
{"type": "line", "line": {"color": "blue"}},
{"type": "spacer", "height": "3mm"},
{"type": "text", "content": "Green line:"},
{"type": "line", "line": {"color": "green"}},
{"type": "spacer", "height": "5mm"}
]}
]}},
{"row": {"cols": [
{"span": 12, "elements": [
{"type": "text", "content": "Thin line (0.5pt):"},
{"type": "line", "line": {"thickness": "0.5pt"}},
{"type": "spacer", "height": "3mm"},
{"type": "text", "content": "Medium line (2pt):"},
{"type": "line", "line": {"thickness": "2pt"}},
{"type": "spacer", "height": "3mm"},
{"type": "text", "content": "Thick line (5pt):"},
{"type": "line", "line": {"thickness": "5pt"}},
{"type": "spacer", "height": "5mm"}
]}
]}},
{"row": {"cols": [
{"span": 12, "elements": [
{"type": "text", "content": "Thick red line (3pt):"},
{"type": "line", "line": {"color": "red", "thickness": "3pt"}},
{"type": "spacer", "height": "3mm"},
{"type": "text", "content": "Thick blue line (4pt):"},
{"type": "line", "line": {"color": "blue", "thickness": "4pt"}}
]}
]}}
]
}
::
Spacers
Add vertical spacing between elements.
::pdf-example{pdf="/pdfs/examples/06_spacer.pdf"}
{
"page": {"size": "A4", "margins": "20mm"},
"body": [
{"row": {"cols": [
{"span": 12, "text": "Spacer Examples", "style": {"size": 18, "bold": true}}
]}},
{"row": {"cols": [
{"span": 12, "elements": [
{"type": "text", "content": "Text before 5mm spacer"},
{"type": "spacer", "height": "5mm"},
{"type": "text", "content": "Text after 5mm spacer"}
]}
]}},
{"row": {"cols": [
{"span": 12, "elements": [
{"type": "text", "content": "Text before 15mm spacer"},
{"type": "spacer", "height": "15mm"},
{"type": "text", "content": "Text after 15mm spacer"}
]}
]}},
{"row": {"cols": [
{"span": 12, "elements": [
{"type": "text", "content": "Text before 30mm spacer"},
{"type": "spacer", "height": "30mm"},
{"type": "text", "content": "Text after 30mm spacer"}
]}
]}}
]
}
::
Page Sizes
Supports A4, A3, Letter, Legal, and custom sizes.
::pdf-example{pdf="/pdfs/examples/15a_pagesize_a4.pdf"}
{
"page": {"size": "A4", "margins": "20mm"},
"body": [
{"row": {"cols": [
{"span": 12, "elements": [
{"type": "text", "content": "Page Size: A4 (210mm x 297mm)", "style": {"size": 20, "bold": true}},
{"type": "spacer", "height": "10mm"},
{"type": "text", "content": "This page demonstrates the A4 (210mm x 297mm) page format."}
]}
]}}
]
}
::
Margins
Custom asymmetric margins for book-style layouts.
::pdf-example{pdf="/pdfs/examples/16_margins.pdf"}
{
"page": {"size": "A4", "margins": "20mm"},
"body": [
{"row": {"cols": [
{"span": 12, "elements": [
{"type": "text", "content": "Custom Margins", "style": {"size": 18, "bold": true}},
{"type": "spacer", "height": "5mm"},
{"type": "text", "content": "This page has asymmetric margins: 10mm top/bottom, 40mm left/right. The wide side margins create a narrower text area, similar to a book layout."},
{"type": "spacer", "height": "5mm"},
{"type": "line"},
{"type": "spacer", "height": "5mm"},
{"type": "text", "content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris."}
]}
]}}
]
}
::
Absolute Positioning
Place elements at exact XY coordinates on the page, independent of the grid flow. Useful for watermarks, stamps, overlays, and fixed-position elements.
::pdf-example{pdf="/pdfs/examples/31_absolute_position.pdf"}
{
"page": {"size": "A4", "margins": "20mm"},
"metadata": {"title": "Absolute Positioning"},
"body": [
{"row": {"cols": [
{"span": 12, "elements": [
{"type": "text", "content": "Absolute Positioning Example", "style": {"size": 18, "bold": true}},
{"type": "spacer", "height": "5mm"},
{"type": "text", "content": "This document demonstrates absolute positioning. Elements below are placed at exact XY coordinates."}
]}
]}}
],
"absolute": [
{
"x": "120mm", "y": "20mm",
"elements": [
{"type": "text", "content": "CONFIDENTIAL", "style": {"size": 20, "bold": true, "color": "red"}}
]
},
{
"x": "30mm", "y": "140mm", "origin": "page",
"elements": [
{"type": "text", "content": "DRAFT", "style": {"size": 60, "bold": true, "color": "#CCCCCC"}}
]
},
{
"x": "0mm", "y": "220mm", "width": "25mm", "height": "25mm",
"elements": [
{"type": "qrcode", "qrcode": {"data": "https://gpdf.dev", "size": "20mm"}}
]
}
]
}
::
Something unclear or missing on this page?