View Source Pdf.Builder (ExPDF v1.0.1)
Declarative PDF builder from template lists.
Renders a list of content tuples into a PDF document, applying global configuration for page size, margins, fonts, and templates.
Example
template = [
{:text, "Title", %{font_size: 24, bold: true}},
{:spacer, 10},
{:text, "Body text", %{font_size: 12}},
{:line, %{color: :gray}},
{:page_break},
{:text, "Page 2", %{font_size: 18}}
]
config = %{
size: :a4,
margin: 40,
font: "Helvetica",
font_size: 12
}
doc = Pdf.Builder.render(template, config)
binary = Pdf.export(doc)
Summary
Functions
Render a template list with the given config into a PDF document.
Render a template list into an existing document. Nested lists are automatically flattened.
Functions
Render a template list with the given config into a PDF document.
Config keys
:size— page size (default:a4):margin— margin value or map (default0):font— default font name (default"Helvetica"):font_size— default font size (default12):compress— compress streams (defaulttrue):header—fn doc, page_info -> doc endtemplate:footer—fn doc, page_info -> doc endtemplate:watermark—fn doc, page_info -> doc endtemplate:background—fn doc, page_info -> doc endtemplate
Render a template list into an existing document. Nested lists are automatically flattened.