Changelog
Release history for @crstnmac/sempdf.
All notable changes to @crstnmac/sempdf are documented here. This project follows Semantic Versioning.
[1.9.0] - 2026-08-14
Added
- Added
PdfDocument.fonts()as a unified font API. Families can now be loaded from raw bytes, local paths, URLs, Google Fonts, WOFF2 files, or TTC face indices, with one document-wide body font, code font, and fallback chain. - Moved the optional offline Liberation preset and its 12 font files to
@crstnmac/sempdf-fonts; the core package no longer carries a 4.36 MB font payload. Useawait doc.fonts(liberation)after importing that preset. - Added
PdfDocument.setTextDefaults()so asynchronously loaded fonts can be applied to existing documents and page builders.
Compatibility
- Existing
createDocument(),embedTrueTypeFont(),registerFontFamily(), and per-callfallbackFontsbehavior is unchanged.
[1.8.2] - 2026-08-13
Changed
- Default PDF producer and related metadata now identify the engine as
sempdf. Documentation, examples, and the MCP server name match.
[1.8.1] - 2026-08-11
Changed
- Simplified headings to one API:
heading()now accepts plain text or rich runs, replacing the redundantheadingWithReference()method. - Consolidated artifact classification into the public content options and removed internal renderer helpers from the published type declarations.
Fixed
- Corrected tagged-PDF footnotes to emit nested reference markers, structured note labels and content, unique note IDs, and preserved link annotations.
- Corrected cross-reference structure so visible text and its annotation share one accessible link hierarchy.
- Serialized classified artifacts as valid marked-content property dictionaries, including pagination header and footer subtypes for page numbers.
- Added accessible names to substring links and prevented artifact-only rich paragraphs from leaving empty structure elements.
[1.8.0] - 2026-08-11
Changed
- Renamed the published package to
@crstnmac/sempdfand configured releases forhttps://nodeproxy.criston.dev/. - Removed all first-party licensing, activation, quota, authorization, and evaluation-watermark behavior. PDF generation and editing now work directly without a license key or guard.
- Renamed the companion MCP package to
@crstnmac/sempdf-mcp; its next release is0.5.0.
Included
- Includes the latest generation, editing, accessibility, document-JSON, HTML-to-PDF, code-block, font-fallback, and compliance improvements recorded in the development history below.
Legacy development history
The entries below describe the source project before the package name and
public version line were reset for @crstnmac/sempdf. They are retained for
technical traceability and do not represent published versions under the new
package name.
[2.5.4] - 2026-08-13
Internal
- Visual regression baselines refreshed. No library change — the published
code is identical to 2.5.3. The invoice fixture baselines had been stale since
2026-05-29, so
visual:comparefailed on every run and could not have caught a real regression. The drift traces to two intentional changes from 2026-06-29: the table-border work, which drops a cell's first text baseline by 0.75 line heights so the top line stays inside a bordered cell, and the bundled-fonts work, which replaced the Standard-14 advance-width heuristic with real font metrics. Rendering has been unchanged from 2.1.0 through 2.5.3;visual:compareis now clean at zero differing pixels.
[2.5.3] - 2026-08-13
Internal
- Cognitive-complexity refactor of the layout and serialization paths. The
largest functions in
src/were split into named steps covering document and incremental serialization, page content streams, annotation dictionaries, table and list layout, HTML parsing, template flow, vertical text positioning, and code-block pagination. Output is byte-identical to 2.5.2. No public API change.
[2.5.2] - 2026-08-13
Changed
- No insecure randomness fallback.
secureRandomBytes(RSA seed/padding for signing) previously fell back toMath.random()whenglobalThis.crypto.getRandomValueswas missing. It now throwsINVALID_ENCRYPTIONinstead, so a runtime without WebCrypto fails loudly rather than producing predictable bytes.
Fixed
- Catastrophic-backtracking risk in three parsers. The HTML tag scanner, SVG attribute scanner, and trailing-whitespace strips now use linear-time parsing operations. Parsing results are unchanged.
- GIF local color tables no longer mis-advance the reader. Dead local color-table state was removed and the byte cursor now advances explicitly.
Internal
- Repo-wide static-analysis sweep: nested ternaries extracted, repeated unions
named, modern string and number APIs preferred, dead stores and imports
removed, duplicate helpers shared, and
imageFitRectnow accepts an options object. Rendered output is byte-identical to 2.5.1. - Dockerfiles install with
npm ci --ignore-scripts; the visual-preview server validates paths against an allow-list and resolves executables only from trusted binary directories.
[2.5.1] - 2026-08-10
Added
defaults.fallbackFonts. A document-wide fallback list, consulted by every text path that omits its own — paragraphs, headings, code, lists, tables, rich runs, and HTML — so a symbol font covering glyphs the body font lacks (✓,✕, arrows, CJK) is configured once atcreateDocumentinstead of on every call. Precedence is per-call → flow state → document default; a per-call list replaces the default rather than extending it, and[]opts a single call out.RichTextOptions.fallbackFontsis new too, so rich runs can set the list at block level.
Fixed
page.list()ignored registered font families. A family name in the list'sfont(or nowfallbackFonts) reached layout unresolved instead of being mapped to a concrete face, so it rendered with the fallback font or threwUNSUPPORTED_CHARACTER.page.list()andcontainer.list()now resolve families like every other block;flow.list()was unaffected.
[2.5.0] - 2026-08-05
Added
- Compliance errors name the offending page and text. A built-in font
error under
pdfua-*/pdfa-*/wtpdfsaid only that embedded fonts were required, leaving the offending content to be hunted by hand. The message now appends the first three offenders (page 2 · font "Courier" · "const answer = 42;") and the issue carries alocationsarray (PdfComplianceLocation[]: 1-basedpage,kind,font,annotation,name,snippet) with up to 25 entries, on bothvalidateCompliance()and theINVALID_COMPLIANCEerror'sdetails.issues. defaults.codeFont. Code content resolves its font as per-callfont→defaults.codeFont→defaults.font→ built-inCourier, coveringflow.code(),codetemplate blocks, and inline<code>/<kbd>/<samp>runs from HTML. Point it at an embedded monospaced family (e.g. the bundled Liberation Mono) to keep listings out of the built-in-font compliance error.
Changed
- Code blocks no longer hardcode built-in
Courier. A document whosedefaults.fontis embedded previously still emitted Courier for every code block, silently failing PDF/UA and PDF/A. Setdefaults.codeFontto keep a monospaced face; documents that set neither default are unaffected.
[2.4.0] - 2026-07-30
Added
- Multi-page continuity for code blocks. A listing that spans pages or
columns already split line-by-line; now it can say so.
continuedLabeldraws a note at the top of every fragment after the first andcontinuesLabelat the bottom of every fragment that carries on — a fixed string, or a callback given{ fragmentIndex, firstLineNumber, lastLineNumber, totalLines }. Notes are artifacts (never read as code) and reserve their own line, so they never overlap the listing. Styled withcontinuationFontSize,continuationColor, andcontinuationAlign. - Open borders at a split. A bordered block now omits the rule under a
fragment that continues and above one that resumes, so consecutive fragments
read as one listing instead of a stack of boxes.
openSplitEdges: falserestores a closed box per fragment.
Changed
- One
Codestructure element per page instead of per fragment. A block that split across the columns of a single page produced a separateCodeelement per column; the fragments now share the page's element, and a new one starts only on a new page.
[2.3.1] - 2026-07-30
Fixed
- A block missing its content field crashed with a bare
TypeError. Template pagination estimates every block's height before any validation runs, so{ type: "paragraph", code }(acodeblock mistyped),{ type: "heading" }with notext, or arichParagraph/list/tablewith noruns/items/rowsdied onCannot read properties of undefined (reading 'replace' | 'map' | 'length')from deep inside layout, naming neither the block nor the field. Every text-bearing block now throwsPdfEngineError(INVALID_TEXT) naming what was expected and which field it belongs in, from both the render and estimate paths. - An
htmlblock given the wrong field rendered nothing at all.{ type: "html", text: "<p>…</p>" }(rather thanhtml) silently produced no output, so content vanished from the document with no error.htmlToBlocks()and thehtmlblock now throwINVALID_TEXTnaming thehtmlfield for a non-string source; an empty or whitespace-only string still yields no blocks, as before.
[2.3.0] - 2026-07-30
Added
- Accent folding, and
normalizeText: "ascii-only". The built-in fonts encode ASCII only, so European text failed withUNSUPPORTED_CHARACTEReven though it has an obvious ASCII form.htmlToBlocks()'s defaultnormalizeText: "ascii"now strips accents through Unicode decomposition (Muñoz→Munoz,café→cafe) plus an explicit map for letters that do not decompose (Æ→AE,ß→ss,Ø→O,Þ→TH,ı→i,Ł→L,ŋ→ng). Characters with no ASCII form — Devanagari, CJK, emoji — are still left alone rather than silently dropped; the new"ascii-only"mode opts into dropping them for pipelines that must never fail and cannot embed a font. The folding helper is exported asfoldToAscii(text, asciiOnly?). - The Latin-1 named entities.
é,ñ,ü,Ø,ß,Æ,þand the rest of the accented set now decode; previously they passed through as literalétext.
Changed
UNSUPPORTED_CHARACTERnow says what failed and how to fix it. The message names the character and its code point ("日" (U+65E5)) and points atregisterBundledFonts()/embedTrueTypeFont()/loadGoogleFont()/fallbackFonts/ text normalization.detailsgainsfontandexcerpt— a window of the surrounding text — so the offending field is findable in a large document.
[2.2.1] - 2026-07-30
Fixed
- A
codeblock with a missing or misnamed source crashed with a bareTypeError. Template pagination estimates every block's height before any text validation runs, so{ type: "code" }with nocodefield (ortextused by mistake, or an undefined database column) reachedestimateCodeHeightand died onCannot read properties of undefined (reading 'replace')with no hint about the cause. Both the render and estimate paths now throwPdfEngineError(INVALID_TEXT) naming thecodefield and the type received. - An empty
codeblock no longer throws or draws an empty band. A blank or whitespace-only source (a CMS field with no content) previously threwINVALID_TEXTfor""yet rendered a stray empty band for" ". Both now render nothing and consume no vertical space.
[2.2.0] - 2026-07-30
Added
-
htmlToBlocks(), anhtmltemplate block, andflow.html()— HTML to PDF blocks. Converts the HTML that CMS fields and rich-text editors emit into template blocks: headings, paragraphs with inline runs, nested ordered/unordered lists, tables (th/scope/colspan/rowspan/caption),precode blocks, blockquotes, rules, and images. Output is ordinary block data, so it paginates, tags itself, feeds the TOC/auto-outline, and takes stylesheets.htmlblocks are expanded before pagination, so headings inside them still reach the TOC — including fromrenderDocumentJson, which lets pure-JSON callers ship rich text. Entity decoding covers named, decimal, hex, and double-encoded (&mdash;) references, exported on its own asdecodeHtmlEntities().normalizeText: "ascii"(default) folds smart quotes, dashes, ,—, arrows, fractions, and currency symbols to ASCII so the built-in ASCII-only fonts render converted content;"none"keeps the original characters for embedded Unicode fonts. Untrusted input is handled by design: scripts, styles, embeds, and form controls are dropped with their content, link schemes are allow-listed (javascript:renders as plain text), and malformed markup recovers instead of throwing. -
codetemplate block andflow.code()— preformatted code blocks. Renders monospaced text with leading whitespace and hard line breaks kept verbatim (paragraphs collapse both), on a background band that repeats on every page or column the block spans, so a code listing longer than a page paginates itself. Options cover typography, band fill/border/padding, tab expansion, soft wrap with a hanging indent (or clipping), a line-number gutter, and ordered regex highlight rules;patternaccepts a string so rules stay JSON-serializable forrenderDocumentJson. Tagged as aCodeelement inside aPby default (tag: "P"or"Artifact"to change it). AddscodeBefore/codeAftertoFlowSpacingScale.
Fixed
- A rich paragraph ignored its runs'
highlightcolor.flow.richParagraph()(and sorichParagraphblocks) pushed underline/strike decorations but never the highlight fills, so a run withhighlightrendered without its background. The page-level rich-text API was unaffected.
[2.1.5] - 2026-07-20
Fixed
- Security: certificate-recipient encryption used a predictable RNG for
cryptographic material.
generateRandom20ByteSeed()(RSA public-key encryption seed) and the PKCS#1 v1.5 padding bytes inrsaEncryptPkcs1were both filled withMath.random()— not cryptographically secure, so the seed and padding were theoretically predictable to an attacker who could observe enough output. Both now draw fromglobalThis.crypto.getRandomValues(CSPRNG), falling back toMath.random()only in runtimes without a Web Crypto API. No API change; affects only documents encrypted for certificate recipients.
[2.1.0] - 2026-07-17
Changed
Added
hsl()color helper.hsl(h, s, l)converts to an RGB color, alongside the existingrgb/cmyk/gray/hex/colorhelpers. Saturation/lightness accept a0–1fraction, a percentage string ("87%"), or a0–100number;color()also parses CSShsl(...)strings (e.g.color("hsl(87, 87%, 80%)")).- Report pagination controls. Every template block now accepts
breakBefore/breakAfter(force a fresh region before/after),keepTogether(never split; for paragraphs this disables column line-splitting), andwidows/orphans(minimum lines to carry into / leave before a break when a paragraph splits across columns). - Table of contents. A
{ type: "toc" }template block builds a linked, page-numbered contents list from the document's heading blocks. Page numbers resolve after layout, so the TOC can sit at the front and point forward. Tagged for PDF/UA as aTOC→TOCI→Reference→Linkhierarchy, with the entry text inside theLink(accessible name) and the link annotation nested in the sameLink. Options:maxLevel,font,fontSize,lineHeight,indent,link,pageNumbers, a decorativeleader("dots"|"line"|"none") withleaderColor(drawn as an artifact so AT never announces it),levelStyles(per-level font/size/color), andnumbering(hierarchicalLblsection numbers like1.2). Page numbers are right-aligned into a column. - Cross-references. Any block can declare a named
anchor; a{ type: "crossRef", to, text }block links to it and substitutes the resolved page number (via a{page}placeholder or appended). - Footnotes. A
footnoteon a text block appends a numbered marker and renders the note at the bottom of the page it lands on; the paginator reserves the space so notes never overlap content. - Smarter tables.
columnWidths: "auto"sizes columns to their content (natural width scaled to fill, shrinking toward the longest word).footerRows: Nrepeats the lastNrows at the bottom of every page when a table splits (mirroringheaderRows). - Image fit, positioning, and clipping. Raster image placements accept
fit("fill"|"contain"|"cover"),position(9 anchors), andclip("none"|"circle"|"ellipse"), applied consistently across page, flow, and template image blocks. - Page background color.
createDocumentaccepts apageBackgroundcolor that fills every page (viaaddPageandrenderTemplate) behind all content, tagged as an artifact;renderTemplatealso accepts apageBackgroundthat overrides it per template. - Watermarks.
renderTemplateaccepts awatermarkoption (a string orTemplateWatermarkOptions) that draws a diagonal, centered, semi-transparent mark behind every page, auto-sized to span the page and always tagged as an artifact. - Master-page backgrounds.
renderTemplateaccepts abackgroundcallback returning blocks drawn behind every page's content (tints, rules, logos). - Rich text in list items. List items accept
InlineTextRun[]bodies (mixed fonts, sizes, colors, bold/italic, links) in addition to plain strings, across page-levellist(), flow lists, and template list blocks — with layout estimation handling the rich runs correctly. - Text formatting run options. Superscript/subscript, baseline
rise, render modes (strokeoutline,fillStroke,invisible), and inlinehighlight(marker-pen fill behind text) — on whole text calls,richText/richParagraphruns, and template paragraphs. - Per-cell table borders. Cells accept individual border overrides (per-side width/color) on top of the table-wide
borders/borderColoroptions. - Liberation fonts bundled. Metric-compatible embedded replacements for Helvetica/Times/Courier (SIL OFL) ship in the package with fetch/verify scripts — the recommended fonts for PDF/UA output, where standard-14 name references don't satisfy the embedded-font requirement.
Fixed
- TOC, footnotes, and cross-references now inherit the selected font from any source. They previously ignored the template's font and rendered in the built-in default. They now resolve the font from
page.font, the documentdefaults.font, or the stylesheetparagraphstyle (still overridable per feature/level). PdfPage.container()andPdfPage.structure()now inherit the document's font families and text defaults. Text drawn through a page-level structure container previously lost the default font and registered families (falling back to Helvetica); this also drove the TOC font regression above.- Master-page background text is no longer clipped off the top of the page. The
backgroundflow started at the exact top edge, so a background paragraph's first line was drawn above the page and never appeared. It now starts at the top content edge like the body flow. - Horizontal text scaling now affects layout.
horizontalScaling(theTzoperator) is now included in width measurement, so wrapping, alignment, justification, and highlight/annotation rectangles are correct for condensed/expanded text.
[2.0.0] - 2026-06-25
[1.9.0] - 2026-06-24
Added
- AES PDF encryption now works in the browser. AES (
aes-128,aes-256,aes-256-r6) previously required Node'scryptoand threw"AES PDF encryption requires Node.js crypto support"in browsers. The library now falls back to a built-in, zero-dependency AES-CBC + SHA-256/384/512 implementation whennode:cryptois unavailable, so encrypting and decrypting run client-side. Output is byte-for-byte compatible with the Node path (verified against Node's native crypto), so a document encrypted in the browser opens with the same password in any reader. Node continues to use its native crypto for speed. The only browser requirement is a secure-random source for the IV/key, read from the Web Crypto API. A "Browser AES encryption" playground sample and docs were added.
[Legacy 1.8.0] - 2026-06-24
Added
- Optional veraPDF validation adapter. New
validateWithVeraPdf(bytes, options)shells out to a veraPDF executable when one is available and returns the supplied custom-checker issues otherwise — veraPDF is never bundled and adds no dependencies. The result reports itssource("verapdf"or"custom"), whether veraPDF wasavailable, thecompliantflag, and issues normalized toPdfComplianceIssue. The flavour is auto-derived from theconformanceprofile (e.g.pdfa-2b→2b,pdfua-1→ua1) or set explicitly; the executable resolves fromverapdfBin, thenVERAPDF_BIN, thenverapdfonPATH. Node-only:node:*modules are imported lazily so browser bundles never reach this code. The defensive report parser is exported separately asparseVeraPdfReport.
[1.7.2] - 2026-06-24
Fixed
- Page- and container-level
table()still ignoredtextDefaults(incomplete 1.7.1 fix).1.7.1seeded the cell base font fromtextDefaultsonly on the flow (flow.table) path. The directpage.table()and structure-containertable()methods passed calloptionsstraight through as the cell base and the table-wide font, so with no per-callfonta styled/header cell hit the hardcodedbase.font ?? "Helvetica"and plain cells inherited an unseeded table font —pdfua-1INVALID_COMPLIANCEagain. Both methods now seedfont/fontSize/color/kerningfromtextDefaults(call options still win). - Page- and container-level
list()had the same gap.page.list()and the structure-containerlist()passedoptionstonormalizeListOptionswithout mergingtextDefaults, so a list with no explicitfontfell back to"Helvetica". They now seed list defaults fromtextDefaultstoo, matching the flow list path fixed in 1.7.1.
[1.7.1] - 2026-06-24
Fixed
- Lists and tables ignored
defaultFont/ documenttextDefaults. Paragraphs and headings inherit document-wide text defaults, but the list and table block paths merged only the flow-configured defaults — never the documenttextDefaults— so list items and table cells fell back to the hardcoded"Helvetica". Underpdfua-1this producedINVALID_COMPLIANCE(visible text in a non-embedded font). List render/estimate and table render/row-height paths now mergetextDefaultsat lowest priority (matching paragraph behavior), and table cell base styling seedsfont/fontSize/color/kerningfromtextDefaultstoo. A font set "for the whole page" now applies to lists and tables without an explicit per-block override. - List height estimate threw when block options were present. The estimate path only injected the auto-width when a list block carried no options, so passing any option (e.g.
font) dropped the width andnormalizeListOptionsthrewwidth must be a finite number. The estimate path now always seeds the flow width, still overridable by an explicitoptions.width.
[1.7.0] - 2026-06-16
Changed
renderTemplatenow wraps all content under a singleDocumentstructure root by default. A template produces a complete document, but without an explicitstructureRootits tagged content (headings, paragraphs, figures, tables) was emitted as a flat list of top-level structure elements directly underStructTreeRoot— PDF/UA-1 expects a single top-levelDocumentelement.renderTemplatenow defaults the structure root toDocumentwhen the document was created without one. PassstructureRoot: falsetocreateDocumentto opt out and keep bare roots; an explicitstructureRootis still respected. The low-leveladdPage/manual-structure API is unaffected (no implicit wrapper).
[1.6.2] - 2026-06-16
Fixed
- Template running header drawn last in the content stream.
1.6.1hoisted a running header's structure roots to the front of the tag tree, but the body was still drawn first in the page content, so the header logoFigurereceived the highest marked-content id (MCID). Reading order and content order disagreed — content-order tools and PDF/UA validators saw the logo last. The header's content operators are now hoisted to the front of the page content stream alongside its structure roots, so the header is drawn first (lowest MCID) and reading order matches content order. Footers/page numbers are unaffected (they correctly remain last). Safe because text operators are self-contained (BT/ETwith an absoluteTm) and image operators are wrapped in their ownq/Q. richParagraphthrew on non-string run text. A run whosetextwasnullorundefined(e.g.localStorage.getItem(...)returningnullon a miss) crashednormalizeRichRunswithCannot read properties of null (reading 'length'). Such runs are now dropped like empty runs, so bad input degrades to nothing instead of aborting the whole render.
[1.6.1] - 2026-06-15
Fixed
- Tagged links never referenced from the structure tree. A link annotation was only tied to a
Linkstructure element when the caller passedtag: "Link"explicitly. Inline links —flow.richParagraphruns, page-levelrichTextruns, table-cell links, and paragraph text-annotation links — and the publicpage.link()omitted it, so the annotation was emitted with no OBJR back-reference (an untagged annotation, a PDF/UA-1 failure). An unspecified link tag now defaults toLink; passtag: "Artifact"to opt out for decorative links. - Inline link text was stranded outside its
Linkelement.flow.richParagraphplaced the visible link glyphs under the surroundingPand left theLinkelement holding only the annotation. The link's text is now grouped inside theLinkstructure element together with its OBJR. - Marked content read after child elements. A structure element's
/Karray always listed child elements before the node's own marked content, so a paragraph like"Page URL: " + linkwas announced as the link first, then the leading text./Know interleaves a node's own marked content with its child elements in content (reading) order; pure containers still keep their children's insertion order, so the hoisted running header is unaffected. - Per-cell header cells emitted no
/Scope. A table cell promoted toTHpurely viacell.header(outside anyheaderRows/headerColumnsband — e.g. a row-label column) was written without a/Scope, which auditors flag as a missing row header. Such cells now default to/Scope /Row(still overridable viacell.scope). - Template running header read last in the tag tree. Headers/footers render after the body, so a header logo
Figurelanded at the end of the page's structure order instead of the start. Header structure roots are now hoisted to the front of the reading order; footers remain last (their correct final-appearance position).
[1.6.0] - 2026-06-10
Added
- WOFF2 decoding — new
@crstnmac/sempdf/woff2subpath export.decodeWoff2(bytes)converts a.woff2file (the format browsers and font CDNs serve) into standard TTF/OTF bytes ready forembedTrueTypeFont()/registerFontFamily(). Implements a zero-dependency Brotli (RFC 7932) decompressor — full prefix codes, context modeling, block switching, and the 122 KB static dictionary with all 121 word transforms — plus WOFF2 glyf/loca triplet reconstruction and hmtx transform reversal. Ships as a separate subpath so the embedded dictionary never loads with the core library.isWoff2(bytes)andbrotliDecompress(bytes)are also exported. loadGoogleFont()now works in browsers: when Google serves a woff2 file, the decoder is loaded on demand and the result is returned as TTF bytes. Node continues to receive a plain.ttf/.otfwith no decoder loaded.- Table cell styling: per-cell
font,color,align, andbackgroundoverrides onTableCellDefinition(joiningbold/italic). Cell fonts resolve registered families and built-in variants. - Table decoration options:
borderColor/borderWidthdraw the cell grid,headerBackgroundfills header cells, andzebra(boolean or color) stripes alternate body rows. All decoration is emitted as tagged-PDF artifacts. - Rich text in table cells: cells accept inline
runsinstead oftext— mixed fonts, sizes, colors, bold/italic, underline/strike, and links wrap together inside the cell, with row heights tracking the tallest line.
Fixed
fallbackFontsentries naming a registered font family never matched (the family name was passed through as if it were a built-in font, so fallback glyph coverage silently failed). Family names infallbackFontsnow resolve to the matching face, honoring the call'sbold/italicflags and case-insensitive matching.
[1.5.5] - 2026-06-10
Added
- Table cells accept
boldanditalicflags ({ text: "Results", header: true, bold: true }). The flags resolve against the table font: a registered family picks the matching face, a built-in base family picks its standard-14 variant. Works inpage.table(),flow.table(), structure-container tables, and templatetableblocks; row heights account for the styled face.
Fixed
- Registered font families did not resolve in
flow.table(),flow.list(), and their height estimators — a template withpage: { font: "Roboto" }and atableorlistblock threwUnknown font "Roboto"even though the family was registered. All table/list entry points now resolve families like the text APIs do.
[1.5.4] - 2026-06-10
Changed
- Font family names are now matched case-insensitively (like CSS
font-family). Registering a font as"Roboto"and referencing it as"roboto"or"ROBOTO"in text/template APIs now works correctly. This applies toregisterFontFamily(),renderTemplate({ fonts }), and all text APIs.
Fixed
loadExtensionFontBytes()now strips"./"prefixes from paths before resolving viachrome.runtime.getURL(), which would otherwise produce URLs that fail to fetch.loadExtensionFontBytes()now accepts absolute extension URLs (chrome-extension://...,moz-extension://...,https://...), passing them through without callinggetURL.loadExtensionFontBytes()wrapsfetchfailures with a detailed diagnostic message mentioningweb_accessible_resources, file path, and case-sensitivity — saving debugging time when a content script can't reach a bundled font.
[1.5.3] - 2026-06-10
Added
renderTemplate()now accepts afontsoption — aRecord<string, FontFamilyInput>of family-name → faces that are registered before the template renders. Faces accept raw bytes, embedded handles, or built-in names.loadExtensionFontFaces(paths)— loads bundled extension font files and returnsFontFamilyInputwithout registering, so it composes directly withrenderTemplate({ fonts }).
[1.5.2] - 2026-06-10
Added
loadExtensionFont(doc, family, paths)andloadExtensionFontBytes(path)— load font files bundled with a Chrome extension viachrome.runtime.getURL()and register them as a font family in one call. Fonts are fetched in parallel and passed toregisterFontFamily(). Exported as@crstnmac/sempdf/chrome-extension-fonts.
[1.5.1] - 2026-06-10
Fixed
PdfFlow.richParagraph()andPdfPage.richText()produced text ops without atag, so the tagged PDF structure tree showed thePelement with empty marked-content identifiers. The block-level tag now flows through to each run's options so the structure tree carries the correct MCIDs.
[1.5.0] - 2026-06-06
Added
renderDocumentJson(document)andrenderDocumentJsonSync(document)— render a PDF from a single, fully serializablePdfDocumentJsonvalue. Fonts are declared by source (base64/ filepath/url/ Google Fonts) and referenced by name; images carry asrcinstead of raw bytes; headers/footers are static block arrays with{{pageNumber}}/{{pageCount}}/{{title}}/{{author}}tokens; document options (encryption, conformance, language, tagged, metadata) live on the root.renderDocumentJsonis async;renderDocumentJsonSynchandles fully inline (base64) documents.- Absolute positioning in
PdfDocumentJson: add aposition({ x, y, width?, height?, page?, origin? }) to a block to draw it at exact PDF-point coordinates instead of flowing. Positionable types:paragraph, the image formats,rect,textField,checkBox,signatureField. PdfDocument.getPage(index, origin?)andPdfDocument.pageCount— return aPdfPagebuilder for an already-created page so finished pages can be drawn on with the absolute-coordinate APIs.PdfErrorCode.INVALID_DOCUMENT_JSONfor a malformedPdfDocumentJson.
Fixed
ParsedPdfDocument.extractText()returned empty text for pages whose content stream was FlateDecode-compressed (common once a page carried a table, list, or header/footer). The extractor decoded the already-inflated lazy-stream bytes a second time and discarded the page; text andToUnicodedecoding now tolerate the pre-decoded bytes.
[1.3.0] - 2026-06-02
Added
- Shape helpers on
PdfPage:rect(),line(),circle(),ellipse()with a simplifiedShapeStyle(inferred fill/stroke paint mode). - Text measurement:
PdfDocument.measureText(),measureTextBlock(), andmeasureRichText()return width/height/line-count without drawing. PdfPage.image()auto-detects the raster format (PNG, JPEG, GIF, BMP, TIFF, WebP, JPEG 2000) from the data.addPage({ origin: "top-left" })flips the y-axis so coordinates grow downward from the top edge — applied across the page drawing, annotation, and form-field methods.underlineandstrikeoptions on text and inline runs, drawn as decorative lines.- Named colors: text/shape
coloroptions accept names like"red", plus acolor()helper that resolves named and#hexcolors. - Shape and image helpers on
PdfStructureContainer(rect,line,circle,ellipse,image,path) andellipse/lineonPdfFlow. registerFontFamily()accepts raw font bytes per face (embedded automatically) in addition to handles and built-in names (FontFamilyInput).- Document-wide shape defaults via
createDocument({ shapeDefaults }), merged beneath per-call styles by the page shape helpers. - Layout-feedback methods
PdfPage.placeText()andplaceTextBlock()that draw and return{ width, height, (lineCount,) endY }for manual stacking. - "Choosing an API" guide page mapping common goals to the right API.
Changed
- The
fontoption now reports a clear "did you mean" error (INVALID_FONT) for an unknown string font instead of silently falling back, suggesting the closest standard-14 name. Unknown page-size names throwINVALID_PAGE_SIZEwith the same suggestion treatment. PdfStructureContainerbuilder methods (text,textBlock,list,table, image,link) now returnthisfor chaining, consistent withPdfPageandPdfFlow.
[1.2.1] - 2026-06-02
Fixed
- The
fonttext option now accepts a font-family name registered withregisterFontFamily()(and anystring-typed value), instead of rejecting it at compile time.PdfFontwidened toFontName | PdfEmbeddedFont | (string & {}), preserving built-in name autocomplete.
[1.2.0] - 2026-06-02
Added
- Inline rich text:
PdfPage.richText()andPdfFlow.richParagraph()lay out an array ofInlineTextRunsegments that flow on the same line and wrap together, each with its own font, weight, size, color, and optionallink. richParagraphtemplate block (TemplateRichParagraphBlock) for inline rich text inrenderTemplate().- Inline rich text supports
align: "justify", line-leveldirection("ltr" | "rtl" | "auto"), andwritingMode: "vertical"(single-column stacking); flow and template rich paragraphs wrap and split across columns and pages. - Vertical alignment:
verticalAlign("top" | "middle" | "bottom") on table cells (TableOptionsdefault and per-TableCellDefinition). - Vertical alignment within a fixed-height box via
height+verticalAlignonTextBlockOptionsandRichTextOptions. - New exported types:
InlineTextRun,RichTextOptions,FlowRichTextOptions,TemplateRichParagraphBlock,VerticalAlign.
[1.1.0] - 2026-06-02
Added
boldanditalictext options that resolve to the matching font face for the standard-14 base families (Helvetica, Times, Courier)PdfDocument.registerFontFamily()to group font faces (built-in or embedded) under a name, selectable with thebold/italicflags- Document-wide text defaults via
createDocument({ defaults })(font, bold, italic, fontSize, color, kerning, direction) - Unit helpers
mm(),cm(),inch(), andpt()for authoring layouts in physical units PdfDocument.save(path)convenience alias forwriteToFile()
Changed
PdfPagebuilder methods (text, images, annotations, form fields, graphics state, transforms) now returnthisfor fluent chainingbold/italic, registered font families, and document defaults resolve uniformly acrosspage.text()/textBlock(), thePdfFlowcursor API,renderTemplate()blocks, and structure containers
[1.0.0] - 2026-05-11
Added
- Zero-dependency PDF 1.4+ generation engine in TypeScript
- PDF 1.5 object streams and 2.0 encryption support
- Text rendering with 14 standard fonts plus embedded TrueType (Unicode, kerning, ligatures, RTL/Arabic)
- Image support: JPEG, PNG (transparency/alpha)
- Tagged PDF for accessibility: PDF/UA-1, structure trees, MCID-based marked content
- Flow-based coordinate-free layout engine
- Template-based report/document rendering with headers, footers, page numbers, and auto-outline
- Forms (AcroForm): text, checkbox, radio, choice, push button, signature
- Annotations: URI links, highlights, notes, free-text
- Encryption: rc4-40, rc4-128, AES-128, AES-256
- PDF parsing and incremental editing: metadata, pages, forms, overlays
- Page transfer utilities: extract, split, merge, append
- Streaming output via ByteSink abstraction
- XMP metadata support
- Linearized (Fast Web View) output for single-page documents
- PDF version auto-detection and conformance validation