Appearance
Changelog
All notable changes to @criston/zeropdf are documented here. This project follows Semantic Versioning.
[1.5.0] - 2026-06-06
Added
renderDocumentJson(document)andrenderDocumentJsonSync(document)— render a PDF from a single, fully serializablePdfDocumentJsonvalue. Closes the three parts of the template API that cannot be expressed as JSON: 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///tokens. Document options (encryption, conformance, language, tagged, metadata) live on the root.renderDocumentJsonis async (assets may load from disk or network);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. Flow and positioned blocks mix in the sameblocksarray. See JSON to PDF. PdfDocument.getPage(index, origin?)andPdfDocument.pageCount— return aPdfPagebuilder for an already-created page (for example one produced byrenderTemplate), so finished pages can be drawn on with the absolute-coordinate APIs.PdfErrorCode.INVALID_DOCUMENT_JSON, thrown for a malformedPdfDocumentJsonwith a message that names the offending path.
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).getObject()inflates a lazy stream while leaving itsFilterin the dict; the extractor then decoded the already-inflated bytes a second time and silently discarded the page. Text andToUnicodedecoding now tolerate the pre-decoded bytes.
[1.4.1] - 2026-06-03
Added
loadGoogleFont(family, { weight, italic, text })— downloads a Google Font and returns its TrueType/OpenType bytes, ready forembedTrueTypeFont()orregisterFontFamily(). Node-first: the Google Fonts API serveswoff2to browsers (which the zero-dependency engine cannot decode) and an embeddable.ttf/.otfto Node. Supports&text=subsetting and a customfetch.
[1.4.0] - 2026-06-03
Added
descriptionoption on all form fields (textField,checkBox,choiceField,radioGroup,pushButton,signatureField, and theirrenderTemplateblocks), emitted as/TU. Assistive technology reads it as the field's accessible name, and it satisfies the "form fields have a description" accessibility check.
Changed
renderTemplatenow tags form-field widgets into the structure tree automatically (defaulttag: "Annot", emitting anOBJRreference), so generated forms pass the "tagged annotations" and "tagged form fields" accessibility checks without per-field configuration. Settag: "Artifact"on a field block to opt out.
[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 chaining.bold/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.