GridScope

Receiver inside grid { ... }. Each child added here becomes one grid cell, filled row-major.

Properties

Link copied to clipboard

Default text style applied to every text call inside this scope unless the call's configuration block overrides individual properties.

Functions

Link copied to clipboard
fun addNode(node: PdfNode)

Appends a custom PdfNode to this container's child list.

Link copied to clipboard
fun anchor(id: String)

Registers a named jump target at this position. Pair with linkToAnchor to build clickable cross-references ("see chapter 3") and tables of contents.

Link copied to clipboard
fun ContainerScope.barChart(series: List<ChartSeries>, width: Dp, height: Dp, showValues: Boolean = true, showAxis: Boolean = true, gridLines: Int = 0, axisColor: PdfColor = PdfColor.Gray, gridColor: PdfColor = PdfColor.LightGray)

Appends a vertical bar chart.

Link copied to clipboard
fun barcode(data: String, symbology: BarcodeSymbology = BarcodeSymbology.Code128, width: Dp? = null, height: Dp = Dp(50f), color: PdfColor = PdfColor.Black, background: PdfColor? = PdfColor.White)

Appends a 1D barcode encoding data with the chosen symbology.

Link copied to clipboard
fun bookmark(title: String, level: Int = 0)

Adds an entry to the document outline — the bookmark sidebar PDF readers show for quick navigation. The entry points at this marker's position in the rendered flow, so place it right before the heading it labels.

Link copied to clipboard
fun box(width: Dp? = null, height: Dp? = null, background: PdfColor? = null, cornerRadius: Dp = Dp.Zero, padding: Padding = Padding.Zero, border: BorderStroke? = null, cornerRadiusEach: CornerRadius? = null, borderEach: BorderSides? = null, backgroundPaint: PdfPaint? = null, clipToBounds: Boolean = false, dropShadow: DropShadow? = null, rotation: Float = 0.0f, opacity: Float = 1.0f, block: BoxScope.() -> Unit)

Appends a Z-stacking container. Children stack along the depth axis: the first added is at the bottom, the last on top. Use this for image overlays, badges, or any composition where children share the same X/Y space.

Link copied to clipboard
fun bulletList(items: List<String>, bullet: String = "•", markerWidth: Dp = 16.dp, spacing: Dp = 4.dp)

Appends a vertical bulleted list — one row per item, each consisting of a bullet marker and the item text on the same line. Wrapping text in an item indents continuation lines under the first text line, not under the bullet, which matches the typical typographic convention for prose lists.

Link copied to clipboard
fun card(background: PdfColor? = PdfColor.White, cornerRadius: Dp = 8.dp, padding: Padding = Padding.all(12.dp), border: BorderStroke? = null, cornerRadiusEach: CornerRadius? = null, borderEach: BorderSides? = null, backgroundPaint: PdfPaint? = null, clipToBounds: Boolean = false, dropShadow: DropShadow? = null, rotation: Float = 0.0f, opacity: Float = 1.0f, block: ColumnScope.() -> Unit)

Convenience shortcut that wraps block in a column inside a decorated box. Equivalent to:

Link copied to clipboard
fun checkBox(name: String, size: Dp = Dp(14f), checked: Boolean = false)

Appends an interactive AcroForm checkbox.

Link copied to clipboard
fun circle(diameter: Dp, fill: PdfColor? = null, fillPaint: PdfPaint? = null, strokeColor: PdfColor? = null, strokeWidth: Dp = Dp.Zero)

Appends a circle of the given diameter. The circle is drawn from a 4-cubic-Bézier path so it stays smooth at any zoom level.

Link copied to clipboard
fun column(spacing: Dp = Dp.Zero, verticalArrangement: VerticalArrangement = VerticalArrangement.Top, horizontalAlignment: HorizontalAlignment = HorizontalAlignment.Start, background: PdfColor? = null, cornerRadius: Dp = Dp.Zero, padding: Padding = Padding.Zero, border: BorderStroke? = null, cornerRadiusEach: CornerRadius? = null, borderEach: BorderSides? = null, backgroundPaint: PdfPaint? = null, clipToBounds: Boolean = false, dropShadow: DropShadow? = null, rotation: Float = 0.0f, opacity: Float = 1.0f, block: ColumnScope.() -> Unit)

Appends a vertical container that stacks its children top-to-bottom.

Link copied to clipboard
fun columns(count: Int = 2, gap: Dp = Dp(16f), spacing: Dp = Dp(6f), block: ColumnScope.() -> Unit)

Appends a newspaper-style multi-column block: the children added in block flow into count equal-width columns, balanced so the columns end up roughly the same height while keeping source order.

Link copied to clipboard
fun dataMatrix(data: String, size: Dp = Dp(100f), color: PdfColor = PdfColor.Black, background: PdfColor? = PdfColor.White)

Appends a Data Matrix (ECC 200) 2D barcode encoding data.

Link copied to clipboard
fun divider(thickness: Dp = Dp(0.5f), color: PdfColor = PdfColor.Gray, style: LineStyle = LineStyle.Solid)

Appends a horizontal divider line that spans the parent's full available width.

Link copied to clipboard
fun ContainerScope.donutChart(slices: List<ChartSeries>, diameter: Dp, holeRatio: Float = 0.55f, showLegend: Boolean = true)

Appends a donut chart — a pie with a circular hole punched in the centre.

Link copied to clipboard
fun ellipse(width: Dp, height: Dp, fill: PdfColor? = null, fillPaint: PdfPaint? = null, strokeColor: PdfColor? = null, strokeWidth: Dp = Dp.Zero)

Appends an ellipse stretched to fit [width] × [height]. Same fill / stroke vocabulary as circle.

Link copied to clipboard
fun freeDraw(width: Dp, height: Dp, block: FreeDrawScope.() -> Unit)

Appends a free-form vector drawing authored in a local coordinate space of (0, 0)(width, height) and scaled into the node's final rectangle. Use it for diagrams, decorations, or any shape the primitive nodes don't cover — everything stays sharp vector output.

Link copied to clipboard
fun grid(columns: Int, spacing: Dp = Dp.Zero, block: GridScope.() -> Unit)

Appends a uniform grid: children added inside block flow row-major into columns equal-width cells. The last row is padded with empty cells so every column keeps the same width.

Link copied to clipboard
fun image(bytes: ByteArray, contentScale: ContentScale = ContentScale.Fit, allowDownScale: Boolean = true, altText: String? = null)

Appends an image rendered at its intrinsic pixel dimensions, mapped 1px → 1pt. Useful when the source asset is already sized for print.

fun image(bytes: ByteArray, width: Dp, contentScale: ContentScale = ContentScale.Fit, allowDownScale: Boolean = true, altText: String? = null)

Appends an image whose width is given and whose height is derived from the intrinsic aspect ratio (sniffed from the PNG/JPEG header).

fun image(bytes: ByteArray, width: Dp, height: Dp, contentScale: ContentScale = ContentScale.Fit, allowDownScale: Boolean = true, altText: String? = null)

Appends an image node with explicit dimensions.

Link copied to clipboard
fun keepTogether(block: ColumnScope.() -> Unit)

Wraps the children added in block in a group the page-break machinery never splits: under the Slice strategy the group moves to a fresh page whole instead of being cut mid-content — the break-inside: avoid of this DSL. Use it for figures with their captions, stat cards, or any cluster where a page break in the middle would read as a bug.

Link copied to clipboard
fun ContainerScope.lineChart(series: List<LineSeries>, width: Dp, height: Dp, strokeWidth: Float = 2.0f, gridLines: Int = 0, showLegend: Boolean = true, axisColor: PdfColor = PdfColor.Gray, gridColor: PdfColor = PdfColor.LightGray)

Appends a multi-series line chart.

fun ContainerScope.lineChart(points: List<Float>, width: Dp, height: Dp, color: PdfColor = PdfColor.Blue, strokeWidth: Float = 2.0f, fillUnderLine: Boolean = false, gridLines: Int = 0, axisColor: PdfColor = PdfColor.Gray, gridColor: PdfColor = PdfColor.LightGray)

Appends a line chart.

Link copied to clipboard
fun link(url: String, block: ColumnScope.() -> Unit)

Wraps the children added inside block in a hyperlink annotation pointing at url. The block contributes whatever visual content the user wants — text, an image, a styled card — and the renderer makes the bounding rectangle clickable in PDF viewers that support link annotations.

Link copied to clipboard
fun linkToAnchor(anchor: String, block: ColumnScope.() -> Unit)

Wraps the content added in block in a clickable region that jumps to the anchor registered under the same id — the internal-link counterpart of link. Forward references are fine: the anchor may appear later in the document.

Link copied to clipboard
fun numberedList(items: List<String>, startAt: Int = 1, markerWidth: Dp = 20.dp, spacing: Dp = 4.dp)

Appends a numbered list — same shape as bulletList but with "1.", "2.", … markers. Use startAt when the list logically continues from another series (e.g. step 4 of a tutorial that already showed steps 1–3 elsewhere).

Link copied to clipboard
fun ContainerScope.pieChart(slices: List<ChartSeries>, diameter: Dp, showLegend: Boolean = true)

Appends a pie chart.

Link copied to clipboard
fun qrCode(data: String, size: Dp = Dp(100f), errorCorrection: QrErrorCorrection = QrErrorCorrection.M, color: PdfColor = PdfColor.Black, background: PdfColor? = PdfColor.White)

Appends a QR code symbol encoding data in byte mode (UTF-8). The symbol is drawn as crisp vector squares, so it scans reliably at any print size, and the smallest QR version that fits the payload at the requested errorCorrection level is selected automatically.

Link copied to clipboard
fun richText(block: RichTextScope.() -> Unit)

Appends a multi-style paragraph. Lets a single paragraph mix bold, italic, coloured, or otherwise differently styled segments without splitting into separate text blocks.

Link copied to clipboard
fun row(spacing: Dp = Dp.Zero, horizontalArrangement: HorizontalArrangement = HorizontalArrangement.Start, verticalAlignment: VerticalAlignment = VerticalAlignment.Top, background: PdfColor? = null, cornerRadius: Dp = Dp.Zero, padding: Padding = Padding.Zero, border: BorderStroke? = null, cornerRadiusEach: CornerRadius? = null, borderEach: BorderSides? = null, backgroundPaint: PdfPaint? = null, clipToBounds: Boolean = false, dropShadow: DropShadow? = null, rotation: Float = 0.0f, opacity: Float = 1.0f, block: RowScope.() -> Unit)

Appends a horizontal container that lays its children left-to-right.

Link copied to clipboard
fun spacer(width: Dp = Dp.Zero, height: Dp = Dp.Zero)

Appends a fixed-size empty area. Useful for explicit gaps that don't belong inside a container's spacing parameter.

Link copied to clipboard
fun ContainerScope.stackedBarChart(groups: List<StackedBarGroup>, width: Dp, height: Dp, showAxis: Boolean = true, gridLines: Int = 0, showLegend: Boolean = true, axisColor: PdfColor = PdfColor.Gray, gridColor: PdfColor = PdfColor.LightGray)

Appends a stacked bar chart.

Link copied to clipboard
fun table(columns: List<TableColumn>, border: TableBorder = TableBorder(), cornerRadius: Dp = Dp.Zero, cellPadding: Padding = Padding.all(Dp(8f)), repeatHeader: Boolean = true, block: TableScope.() -> Unit)

Appends a tabular layout with the given columns and arbitrary rows.

Link copied to clipboard
fun tableOfContents(maxLevel: Int = 1, indentPerLevel: Dp = Dp(14f), spacing: Dp = Dp(6f))

Appends an automatically generated table of contents.

Link copied to clipboard
fun text(value: String, block: TextScope.() -> Unit = {})

Appends a text node.

Link copied to clipboard
fun textField(name: String, width: Dp, height: Dp = Dp(24f), value: String = "", multiline: Boolean = false)

Appends an interactive AcroForm text input field — a fillable box in the produced PDF.

Link copied to clipboard
fun vector(image: VectorImage, width: Dp? = null, height: Dp? = null, tint: PdfColor? = null, strokeMode: VectorStrokeMode = VectorStrokeMode.Inherit)

Appends a vector icon previously parsed with VectorImage.parse.

fun vector(xml: String, width: Dp? = null, height: Dp? = null, tint: PdfColor? = null, strokeMode: VectorStrokeMode = VectorStrokeMode.Inherit)

Convenience overload that parses xml on the fly and embeds the resulting vector. Prefer the VectorImage overload when the same icon is reused several times — parsing is not free.

Link copied to clipboard
fun weighted(weight: Float, block: ColumnScope.() -> Unit)

Wraps the children added inside block so that the layout engine gives them a proportional share of the parent container's remaining space along the main axis.