ContentStreamBuilder

Builds a page content stream (ISO 32000-1 §8–§9) from typed drawing operations, emitting the raw operator bytes. Each PDF operator takes its operands first, then the operator keyword: r g b rg, x y m, (str) Tj.

Coordinates are in the default user space (origin bottom-left, points). Numbers are formatted without scientific notation (via PdfObjectWriter); names and strings are escaped the same way the serializer escapes them.

Fonts and images are referenced through fontResolver / imageResolver, which map a StandardFont / PdfImage to the resource name the owning PdfBuilder will register in /Resources.

Functions

Link copied to clipboard
Link copied to clipboard

Intersect the clipping path with the current path using the nonzero winding rule (W). Per the spec, a path-painting operator must follow — call endPath to clip without also painting the path, e.g. rectangle(...); clip(); endPath().

Link copied to clipboard

Like clip, but with the even-odd rule (W*).

Link copied to clipboard
Link copied to clipboard
fun drawImage(image: PdfImage, x: Double, y: Double, width: Double, height: Double): ContentStreamBuilder

Draw image into the rectangle (x, y) → (x+width, y+height) in user space (x, y is the bottom-left corner). Wrapped in its own q … Q so the image transform doesn't leak into later drawing.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Escape hatch: append literal content-stream source, followed by a newline.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun text(font: StandardFont, size: Double, x: Double, y: Double, text: String): ContentStreamBuilder

Convenience: draw a single line of text in font at size, with its baseline at (x, y). Wraps BT/Tf/Td/Tj/ET.

Link copied to clipboard

Concatenate a b c d e f onto the current transformation matrix (cm).