takumi-pdf 0.3.0 → 0.4.1

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/README.md CHANGED
@@ -188,6 +188,8 @@ Omit `metadata` to keep output byte-identical across runs.
188
188
 
189
189
  Output is **tagged by default**: HTML semantics (`h1`–`h6`, `p`, `img` with `alt`, `a`, lists) become a PDF structure tree, like Chromium's print-to-PDF. Set `tagged: "ua1"` to validate against PDF/UA-1, or `tagged: false` to drop the tree when file size matters more than accessibility.
190
190
 
191
+ `<table>` markup is not supported, and a table built out of flex rows carries no `Table` structure elements.
192
+
191
193
  `pdfa` renders archival output. Validation runs during rendering. A document that cannot conform fails with the violated rule instead of writing a broken file. Every level, and PDF/UA-1, passes [veraPDF](https://verapdf.org).
192
194
 
193
195
  ```tsx
@@ -205,6 +207,7 @@ const pdf = await render(report, {
205
207
  | `"2a"` / `"3a"` | A tagged structure tree. |
206
208
  | `"3b"` / `"3u"` / `"3a"` | Arbitrary file attachments. |
207
209
  | `"4"` | The PDF 2.0 revision of the standard. |
210
+ | `"4f"` | PDF 2.0 with file attachments. |
208
211
 
209
212
  Invalid combinations are **TypeScript type errors**. See the [PDF/A docs](https://takumi.kane.tw/docs/pdf/pdf-a) for the structure-tree mapping and required metadata.
210
213
 
package/dist/export.d.cts CHANGED
@@ -151,6 +151,37 @@ type PdfMetadata = {
151
151
  * standards require one; supplying it keeps output deterministic.
152
152
  */
153
153
  creationDate?: string;
154
+ /**
155
+ * Custom XMP schemas written into the packet, for metadata the renderer
156
+ * knows nothing about, e.g. the `fx:` properties a Factur-X invoice needs.
157
+ */
158
+ xmp?: XmpSchema[];
159
+ };
160
+ /**
161
+ * A namespace written into the XMP packet, with the schema description PDF/A
162
+ * requires for it.
163
+ */
164
+ type XmpSchema = {
165
+ /** Human-readable name, e.g. "Factur-X PDF/A Extension". */
166
+ name: string;
167
+ /** Namespace prefix the properties are written under, e.g. "fx". */
168
+ prefix: string;
169
+ /** Namespace URI. */
170
+ namespace: string;
171
+ /**
172
+ * Properties written under the namespace. Each is written as a value and
173
+ * described in the schema, so the two cannot drift apart.
174
+ */
175
+ properties: XmpProperty[];
176
+ };
177
+ /** A property of an {@link XmpSchema}. */
178
+ type XmpProperty = {
179
+ /** Property name, e.g. "DocumentFileName". */
180
+ name: string;
181
+ /** Property value. */
182
+ value: string;
183
+ /** What the property means. PDF/A requires one. */
184
+ description: string;
154
185
  };
155
186
  /** A file attached to the PDF, shown in the viewer's attachment panel. */
156
187
  type Attachment = {
@@ -182,7 +213,7 @@ type ArchivalAttachment = Attachment & {
182
213
  * Standards conformance. Invalid combinations are type errors: the `a` levels
183
214
  * imply a structure tree so `tagged: false` is rejected, PDF/A-4 is PDF 2.0
184
215
  * while PDF/UA-1 is PDF 1.7-only so they cannot combine, and only the
185
- * PDF/A-3 levels (or plain PDF) accept attachments.
216
+ * PDF/A-3 levels, PDF/A-4f (or plain PDF) accept attachments.
186
217
  */
187
218
  type ConformanceOptions = {
188
219
  pdfa?: never;
@@ -211,6 +242,10 @@ type ConformanceOptions = {
211
242
  pdfa: "4";
212
243
  tagged?: boolean;
213
244
  attachments?: never;
245
+ } | {
246
+ pdfa: "4f";
247
+ tagged?: boolean;
248
+ attachments?: ArchivalAttachment[];
214
249
  };
215
250
  type RenderOptions = (PagedOptions | ViewportOptions) & ConformanceOptions & {
216
251
  /** Fonts to register before rendering, deduped across calls. */
@@ -256,4 +291,4 @@ declare function render(node: NodeInput, options?: RenderOptions): Promise<Uint8
256
291
  /** Measures with a lazily created shared {@link PdfRenderer}. */
257
292
  declare function measure(node: NodeInput, options?: MeasureOptions): Promise<MeasuredSize>;
258
293
  //#endregion
259
- export { ArchivalAttachment, Attachment, Dimensions, type FontLoader, type ImagesInput, MeasureOptions, MeasuredSize, NodeInput, PageMargin, PageSize, PdfMetadata, PdfRenderer, RenderOptions, ViewportInput, __wbg_init as default, initSync, measure, render };
294
+ export { ArchivalAttachment, Attachment, Dimensions, type FontLoader, type ImagesInput, MeasureOptions, MeasuredSize, NodeInput, PageMargin, PageSize, PdfMetadata, PdfRenderer, RenderOptions, ViewportInput, XmpProperty, XmpSchema, __wbg_init as default, initSync, measure, render };
package/dist/export.d.mts CHANGED
@@ -151,6 +151,37 @@ type PdfMetadata = {
151
151
  * standards require one; supplying it keeps output deterministic.
152
152
  */
153
153
  creationDate?: string;
154
+ /**
155
+ * Custom XMP schemas written into the packet, for metadata the renderer
156
+ * knows nothing about, e.g. the `fx:` properties a Factur-X invoice needs.
157
+ */
158
+ xmp?: XmpSchema[];
159
+ };
160
+ /**
161
+ * A namespace written into the XMP packet, with the schema description PDF/A
162
+ * requires for it.
163
+ */
164
+ type XmpSchema = {
165
+ /** Human-readable name, e.g. "Factur-X PDF/A Extension". */
166
+ name: string;
167
+ /** Namespace prefix the properties are written under, e.g. "fx". */
168
+ prefix: string;
169
+ /** Namespace URI. */
170
+ namespace: string;
171
+ /**
172
+ * Properties written under the namespace. Each is written as a value and
173
+ * described in the schema, so the two cannot drift apart.
174
+ */
175
+ properties: XmpProperty[];
176
+ };
177
+ /** A property of an {@link XmpSchema}. */
178
+ type XmpProperty = {
179
+ /** Property name, e.g. "DocumentFileName". */
180
+ name: string;
181
+ /** Property value. */
182
+ value: string;
183
+ /** What the property means. PDF/A requires one. */
184
+ description: string;
154
185
  };
155
186
  /** A file attached to the PDF, shown in the viewer's attachment panel. */
156
187
  type Attachment = {
@@ -182,7 +213,7 @@ type ArchivalAttachment = Attachment & {
182
213
  * Standards conformance. Invalid combinations are type errors: the `a` levels
183
214
  * imply a structure tree so `tagged: false` is rejected, PDF/A-4 is PDF 2.0
184
215
  * while PDF/UA-1 is PDF 1.7-only so they cannot combine, and only the
185
- * PDF/A-3 levels (or plain PDF) accept attachments.
216
+ * PDF/A-3 levels, PDF/A-4f (or plain PDF) accept attachments.
186
217
  */
187
218
  type ConformanceOptions = {
188
219
  pdfa?: never;
@@ -211,6 +242,10 @@ type ConformanceOptions = {
211
242
  pdfa: "4";
212
243
  tagged?: boolean;
213
244
  attachments?: never;
245
+ } | {
246
+ pdfa: "4f";
247
+ tagged?: boolean;
248
+ attachments?: ArchivalAttachment[];
214
249
  };
215
250
  type RenderOptions = (PagedOptions | ViewportOptions) & ConformanceOptions & {
216
251
  /** Fonts to register before rendering, deduped across calls. */
@@ -256,4 +291,4 @@ declare function render(node: NodeInput, options?: RenderOptions): Promise<Uint8
256
291
  /** Measures with a lazily created shared {@link PdfRenderer}. */
257
292
  declare function measure(node: NodeInput, options?: MeasureOptions): Promise<MeasuredSize>;
258
293
  //#endregion
259
- export { ArchivalAttachment, Attachment, Dimensions, type FontLoader, type ImagesInput, MeasureOptions, MeasuredSize, NodeInput, PageMargin, PageSize, PdfMetadata, PdfRenderer, RenderOptions, ViewportInput, __wbg_init as default, initSync, measure, render };
294
+ export { ArchivalAttachment, Attachment, Dimensions, type FontLoader, type ImagesInput, MeasureOptions, MeasuredSize, NodeInput, PageMargin, PageSize, PdfMetadata, PdfRenderer, RenderOptions, ViewportInput, XmpProperty, XmpSchema, __wbg_init as default, initSync, measure, render };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "takumi-pdf",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "description": "HTML/JSX to paged, selectable-text PDF, powered by takumi. WebAssembly, no Chromium.",
5
5
  "keywords": [
6
6
  "css",
@@ -83,7 +83,7 @@
83
83
  "publish-lint": "attw --pack . && publint --strict ."
84
84
  },
85
85
  "dependencies": {
86
- "@takumi-rs/helpers": "2.5.10"
86
+ "@takumi-rs/helpers": "2.5.11"
87
87
  },
88
88
  "devDependencies": {
89
89
  "@types/bun": "^1.3.14",
Binary file