pretext-pdf 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,15 +7,79 @@ Format: [Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/)
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
- ### Planned (Phase 8)
11
-
12
- - Phase 8A: Comments/Annotations (sticky notes on elements)
13
- - Phase 8B: Forms (text fields, checkboxes, radio buttons, dropdowns)
14
- - Phase 8C: Document assembly (merge multiple PDFs, file attachments)
15
- - Phase 8D: Advanced layout (image floats, callout boxes)
16
- - Phase 8E: Digital signatures (visual + cryptographic signing)
17
- - Phase 8F: Font subsetting improvements (reduce file size)
18
- - Phase 8H: Inline formatting (superscript, subscript, letter spacing)
10
+ ### Planned (Phase 9+)
11
+
12
+ - Phase 9A: Digital signatures (cryptographic PKCS#7 via `@signpdf/signpdf`)
13
+ - Phase 9B: Image floats (text flowing alongside images requires paginator rewrite)
14
+ - Phase 9C: Font subsetting pre-computation (explicit glyph hints for icon fonts)
15
+
16
+ ---
17
+
18
+ ## [0.3.0] 2026-04-08
19
+
20
+ ### Added (Phase 8B — Interactive Forms)
21
+ - New `form-field` element type — creates interactive AcroForm fields in PDFs
22
+ - `fieldType: 'text' | 'checkbox' | 'radio' | 'dropdown' | 'button'`
23
+ - `label` renders above the field as static text
24
+ - Text fields: `defaultValue`, `multiline`, `placeholder`, `maxLength`
25
+ - Checkboxes: `checked` initial state
26
+ - Radio groups and dropdowns: `options` array, `defaultSelected`
27
+ - `doc.flattenForms: true` — bakes all fields into static content
28
+ - Custom `borderColor`, `backgroundColor`, `width`, `height`, `fontSize` per field
29
+ - New error codes: `FORM_FIELD_NAME_DUPLICATE` (duplicate `name` across fields), `FORM_FLATTEN_FAILED`
30
+ - Post-render `form.updateFieldAppearances()` ensures proper display in all PDF readers
31
+ - 10 comprehensive tests covering all form field types
32
+
33
+ ### Added (Phase 8E — Signature Placeholder)
34
+ - `doc.signature` — visual signature box drawn on a specified page
35
+ - Fields: `signerName`, `reason`, `location`, `x`, `y`, `width`, `height`, `page`, `borderColor`, `fontSize`
36
+ - Draws signature line, date line, and optional text inside a bordered rectangle
37
+ - `page` is 0-indexed, defaults to last page, clamps gracefully if out of range
38
+ - 6 comprehensive tests
39
+
40
+ ### Added (Phase 8D — Callout Boxes)
41
+ - New `callout` element type — styled highlight box with optional title
42
+ - Preset styles: `style: 'info'` (blue), `'warning'` (amber), `'tip'` (green), `'note'` (gray)
43
+ - Optional `title` rendered bold above content with left border accent
44
+ - Fully customizable: `backgroundColor`, `borderColor`, `color`, `titleColor`, `padding`
45
+ - Paginates correctly across pages (reuses blockquote pagination logic)
46
+ - 8 comprehensive tests
47
+
48
+ ### Added (Phase 8F — Document Metadata Extensions)
49
+ - `doc.metadata.language` — sets PDF `/Lang` catalog entry (BCP47 tag e.g. `'en-US'`, `'hi'`)
50
+ - `doc.metadata.producer` — sets PDF producer field (e.g. `'MyApp v2.1'`)
51
+ - Both fields validate as non-empty strings
52
+ - 5 comprehensive tests
53
+
54
+ ---
55
+
56
+ ## [0.2.0] — 2026-04-08
57
+
58
+ ### Added (Phase 8H — Inline Formatting)
59
+ - `verticalAlign: 'superscript' | 'subscript'` on `InlineSpan` in rich-paragraphs
60
+ - Superscript renders at 65% font size, baseline shifted up by 40% of font size
61
+ - Subscript renders at 65% font size, baseline shifted down by 20% of font size
62
+ - `letterSpacing?: number` on `ParagraphElement`, `HeadingElement`, `RichParagraphElement` — extra pt between characters
63
+ - `smallCaps?: boolean` on those same three element types — simulated via uppercase + 80% fontSize
64
+ - Character-by-character rendering for letterSpacing (pdf-lib has no native spacing param)
65
+ - 8 comprehensive tests covering all inline formatting functionality
66
+
67
+ ### Added (Phase 8A — Annotations/Comments)
68
+ - New `comment` element type — sticky note annotation at position in document
69
+ - `annotation?: AnnotationSpec` on `ParagraphElement` and `HeadingElement` — attach note to element
70
+ - Supports: `contents`, `author`, `color` (hex), `open` (popup default state)
71
+ - Uses PDF `Subtype: 'Text'` annotation (sticky note icon in PDF viewers)
72
+ - 8 comprehensive tests covering all annotation functionality
73
+
74
+ ### Added (Phase 8C — Document Assembly)
75
+ - New `merge(pdfs: Uint8Array[])` exported function — combine pre-rendered PDFs
76
+ - New `assemble(parts: AssemblyPart[])` exported function — mix rendered docs + existing PDFs
77
+ - `AssemblyPart` interface: `{ doc?: PdfDocument, pdf?: Uint8Array }`
78
+ - New error codes: `ASSEMBLY_EMPTY`, `ASSEMBLY_FAILED`
79
+ - 8 comprehensive tests covering all assembly functionality
80
+
81
+ ### Fixed
82
+ - **CI case-sensitivity bug**: `test/phase-7-integration.test.ts` used `'en-US'` (uppercase) for hyphenation language. On Linux CI (case-sensitive filesystem) this failed with `UNSUPPORTED_LANGUAGE`. Changed to `'en-us'` to match package name `hyphenation.en-us`.
19
83
 
20
84
  ---
21
85