sempdf
sempdf v1.9.1Interfaces

Interface: FlowCodeOptions

sempdf v1.9.1


sempdf / FlowCodeOptions

Defined in: src/types.ts:1356

Options for placing a preformatted code block through the flow layout API.

Unlike paragraphs, code blocks preserve leading whitespace and hard line breaks verbatim, never re-flow words between lines, and split across pages or columns line-by-line (each fragment repeats the background band).

Extends

Properties

PropertyTypeDescriptionInherited fromDefined in
background?ColorInput | "none"Background fill behind the block. Pass "none" to draw no background.-src/types.ts:1370
blockAlign?BlockAlignAlignment of the block inside the flow column.-src/types.ts:1435
blockWidth?numberOptional width for the block within the flow column.-src/types.ts:1433
borderColor?ColorInputBorder color. A border is drawn only when this or borderWidth is set.-src/types.ts:1372
borderWidth?numberBorder width in points. Defaults to 0.5 when borderColor is set.-src/types.ts:1374
color?ColorInputCode text color. Defaults to #1f2328.-src/types.ts:1366
continuationAlign?"left" | "right"Alignment of continuation notes within the band. Defaults to "right".-src/types.ts:1418
continuationColor?ColorInputColor for continuation notes. Defaults to lineNumberColor.-src/types.ts:1416
continuationFontSize?numberFont size for continuation notes. Defaults to fontSize * 0.85.-src/types.ts:1414
continuedLabel?string | ((info) => string)Note drawn at the top of every fragment after the first, marking it as the continuation of a block that started on an earlier page or column. Pass a string, or a function for line-aware text. Rendered as an artifact, so it is never read as code. Off by default. Example continuedLabel: ({ firstLineNumber }) => … continued from line ${firstLineNumber - 1}``-src/types.ts:1404
continuesLabel?string | ((info) => string)Note drawn at the bottom of every fragment that carries on into the next page or column. Rendered as an artifact. Off by default. Example continuesLabel: "continues on next page →"-src/types.ts:1412
fallbackFonts?PdfFont[]Fallback fonts used when the primary font lacks a glyph.-src/types.ts:1360
firstLineNumber?numberNumber given to the first line when lineNumbers is set. Defaults to 1.-src/types.ts:1388
font?PdfFontFont used to render the code. Defaults to Courier.-src/types.ts:1358
fontSize?numberFont size in PDF points. Defaults to 9.-src/types.ts:1362
gutterGap?numberGap between the line-number gutter and the code, in points. Defaults to 6.-src/types.ts:1392
highlight?readonly CodeHighlightRule[]Regex colouring rules applied to each rendered line.-src/types.ts:1394
kerning?booleanWhether kerning should be applied. Defaults to false so columns align.-src/types.ts:1368
lineHeight?numberBaseline-to-baseline distance in points. Defaults to fontSize * 1.35.-src/types.ts:1364
lineNumberColor?ColorInputLine-number color. Defaults to a muted grey.-src/types.ts:1390
lineNumbers?booleanWhether to render a line-number gutter. Defaults to false.-src/types.ts:1386
margin?FlowMarginShorthandCSS-like margin shorthand in PDF points.FlowBlockSpacingOptions.marginsrc/types.ts:1271
marginBottom?numberBottom margin in PDF points.FlowBlockSpacingOptions.marginBottomsrc/types.ts:1277
marginLeft?numberLeft margin in PDF points.FlowBlockSpacingOptions.marginLeftsrc/types.ts:1279
marginRight?numberRight margin in PDF points.FlowBlockSpacingOptions.marginRightsrc/types.ts:1275
marginTop?numberTop margin in PDF points.FlowBlockSpacingOptions.marginTopsrc/types.ts:1273
openSplitEdges?booleanWhether a bordered block leaves its border open where it was split — no rule along the bottom of a fragment that continues, none along the top of one that resumes — so the reader sees one listing rather than several boxes. Defaults to true.-src/types.ts:1425
padding?numberInner padding between the background band and the code, in points. Defaults to 8.-src/types.ts:1376
tabSize?numberSpaces a tab expands to. Defaults to 4.-src/types.ts:1378
tag?"P" | "Code" | "Artifact"Structure tagging. "Code" (default) emits a P wrapper containing a Code element, "P" tags the fragment as a plain paragraph, and "Artifact" leaves the content untagged.-src/types.ts:1431
wrap?booleanWhether lines wider than the content width soft-wrap onto continuation lines (indented to match the wrapped line's own indentation). When false, long lines are clipped to the content width. Defaults to true.-src/types.ts:1384

On this page