@imggion/html2realpdf 0.1.13 → 0.1.14-rc2

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/dist/types.d.ts CHANGED
@@ -202,7 +202,7 @@ export interface RenderOptions {
202
202
  pageBreak?: PageBreakRules;
203
203
  /** PDF information dictionary fields. */
204
204
  metadata?: PdfMetadata;
205
- /** Preserves PDF link annotations unless explicitly set to `false`. */
205
+ /** Preserves HTTP(S), mail, telephone, and FTP annotations unless explicitly set to `false`. */
206
206
  enableLinks?: boolean;
207
207
  /**
208
208
  * Rejects the caller at snapshot and render boundaries when aborted.
@@ -258,7 +258,7 @@ export interface Html2PdfOptions {
258
258
  margin?: Margin;
259
259
  /** Filename used by `save` when no method argument is supplied. */
260
260
  filename?: string;
261
- /** Preserves links unless explicitly disabled. */
261
+ /** Preserves HTTP(S), mail, telephone, and FTP links unless explicitly disabled. */
262
262
  enableLinks?: boolean;
263
263
  /** Compatibility pagination rules. */
264
264
  pagebreak?: CompatPageBreakOptions;
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG","sourcesContent":["/**\n * Public configuration and callback contracts for the browser wrapper.\n *\n * @packageDocumentation\n */\n\n/** A structural ref accepted without making React a runtime dependency. */\nexport type RefLike<T> = { readonly current: T | null };\n\n/**\n * Input accepted by the snapshot boundary.\n *\n * @remarks\n * Mounted elements and refs preserve computed styles and live browser state;\n * strings are evaluated in an inert document.\n */\nexport type HtmlSource = string | Element | RefLike<Element>;\n\n/** Units used for custom page dimensions and margins. */\nexport type LengthUnit = \"pt\" | \"px\" | \"mm\" | \"cm\" | \"in\";\n\n/** Named physical page sizes or a custom `[width, height]` in the selected unit. */\nexport type PageFormat = \"a4\" | \"letter\" | readonly [width: number, height: number];\n\n/** Orientation applied after resolving the page format. */\nexport type PageOrientation = \"portrait\" | \"landscape\";\n\n/**\n * Layout and CSS support profile.\n *\n * @remarks\n * `document` favors stable paged reports. `web` enables the broader browser\n * layout profile. `strict` uses that broader profile and rejects unsupported\n * CSS by default.\n */\nexport type CssProfile = \"document\" | \"web\" | \"strict\";\n\n/** Media environment used while resolving styles and media queries. */\nexport type MediaType = \"screen\" | \"print\";\n\n/** Containing block used for the snapshotted root element. */\nexport type LayoutContext = \"source\" | \"page\";\n\n/** Action taken when an authored CSS property is outside the selected profile. */\nexport type UnsupportedCssPolicy = \"warn\" | \"error\" | \"ignore\";\n\n/** Policy for SVG subtrees that cannot remain native PDF vectors. */\nexport type FallbackPolicy = \"error\" | \"rasterize-subtree\";\n\n/** Policy used when a canvas-to-SVG adapter intentionally returns `null`. */\nexport type CanvasFallbackPolicy = \"error\" | \"rasterize\";\n\n/** Complete SVG returned by a canvas adapter. */\nexport type CanvasSvgSource = string | Blob | SVGSVGElement;\n\n/** Context passed to a canvas-to-SVG adapter. */\nexport interface CanvasToSvgRequest {\n /** Original live canvas, suitable for chart-library export APIs. */\n canvas: HTMLCanvasElement;\n /** Stable snapshot path used to identify failures and fallbacks. */\n nodePath: string;\n /** Rendered canvas width in CSS pixels. */\n cssWidth: number;\n /** Rendered canvas height in CSS pixels. */\n cssHeight: number;\n /** Backing bitmap width. */\n bitmapWidth: number;\n /** Backing bitmap height. */\n bitmapHeight: number;\n}\n\n/**\n * Replaces a live canvas with vector SVG when the source library can export it.\n *\n * @remarks\n * Returning `null` delegates to `canvasFallback`. Throwing or returning\n * malformed SVG produces `CanvasToSvgError`.\n */\nexport type CanvasToSvg = (\n request: CanvasToSvgRequest,\n) => CanvasSvgSource | null | Promise<CanvasSvgSource | null>;\n\n/** Deterministic viewport used for responsive layout and media queries. */\nexport interface ViewportOptions {\n /** Viewport width in CSS pixels. Values below one are clamped. */\n width: number;\n /** Viewport height in CSS pixels. Values below one are clamped. */\n height: number;\n}\n\n/**\n * Page margins in the selected page unit.\n *\n * @remarks\n * Four values use html2pdf.js order `[top, left, bottom, right]`, not CSS\n * shorthand order. Two values mean `[vertical, horizontal]`.\n */\nexport type Margin =\n | number\n | readonly [vertical: number, horizontal: number]\n | readonly [top: number, left: number, bottom: number, right: number];\n\n/** Explicit page geometry. Supplying this overrides captured `@page` geometry. */\nexport interface PageOptions {\n /** Page size. Defaults to `a4`. */\n format?: PageFormat;\n /** Page orientation. Defaults to `portrait`. */\n orientation?: PageOrientation;\n /** Unit for custom dimensions and margins. Defaults to `pt`. */\n unit?: LengthUnit;\n /** Page margins. Defaults to zero on every edge. */\n margin?: Margin;\n}\n\n/** Coarse rendering phases reported at stable cancellation boundaries. */\nexport type RenderPhase = \"snapshot\" | \"wasm\" | \"complete\";\n\n/** Progress notification for a rendering phase. */\nexport interface RenderProgress {\n /** Phase producing this notification. */\n phase: RenderPhase;\n /** Completed work units within the phase. */\n completed: number;\n /** Total work units within the phase. */\n total: number;\n}\n\n/** Structured warning or error produced without losing successful PDF output. */\nexport interface Diagnostic {\n /** Stable machine-readable identifier. */\n code: string;\n /** Diagnostic severity assigned by the snapshot or native renderer. */\n severity: \"warning\" | \"error\";\n /** Human-readable explanation. */\n message: string;\n /** CSS property associated with the diagnostic, when applicable. */\n property?: string;\n /** Stable snapshot path to the affected node, when available. */\n nodePath?: string;\n /** Pipeline phase that produced the diagnostic. */\n phase?: \"snapshot\" | \"parse\" | \"cascade\" | \"computed\" | \"layout\" | \"fragmentation\" | \"paint\" | \"pdf\";\n /** Fallback that preserved output despite the unsupported input. */\n fallback?: string;\n}\n\n/** Resource requested while materializing a self-contained snapshot. */\nexport interface ResourceRequest {\n /** Resource class. Fonts are registered on `createRenderer` instead. */\n kind: \"image\" | \"stylesheet\";\n /** Absolute URL resolved against `baseUrl` or the source document. */\n url: URL;\n}\n\n/**\n * Resolves resources that cannot be fetched directly by the browser snapshot.\n *\n * @remarks\n * For stylesheets, a string is CSS source. For images, a string is a data URL\n * or replacement URL. `null` leaves the request unresolved and applies\n * `resourcePolicy`.\n */\nexport type ResourceResolver = (request: ResourceRequest) => Blob | string | null | Promise<Blob | string | null>;\n\n/** Selector-driven pagination overrides compatible with html2pdf.js workflows. */\nexport interface PageBreakRules {\n /** Selectors forced to begin on a new page. */\n before?: string | readonly string[];\n /** Selectors forced to end the current page. */\n after?: string | readonly string[];\n /** Selectors whose contents should avoid internal fragmentation. */\n avoid?: string | readonly string[];\n /** Applies `break-inside: avoid` to every element. */\n avoidAll?: boolean;\n /** Honors the legacy `.html2pdf__page-break` marker. */\n legacy?: boolean;\n}\n\n/** PDF information dictionary fields written by the native renderer. */\nexport interface PdfMetadata {\n /** Document title. */\n title?: string;\n /** Document author. */\n author?: string;\n /** Document subject. */\n subject?: string;\n /** Search keywords, joined when supplied as an array. */\n keywords?: string | readonly string[];\n /** Application or service that created the document. */\n creator?: string;\n}\n\n/** Options applied to one HTML snapshot and PDF render. */\nexport interface RenderOptions {\n /** Explicit page geometry; captured `@page` rules are used when omitted. */\n page?: PageOptions;\n /**\n * Promotes unsupported snapshot CSS to errors without selecting the `web`\n * layout profile. An explicit `unsupportedCss` policy takes precedence.\n */\n strict?: boolean;\n /** Layout profile. Defaults to `document`. */\n cssProfile?: CssProfile;\n /** Media environment used for style resolution. Defaults to `screen`. */\n mediaType?: MediaType;\n /**\n * Root layout context. `source` preserves the mounted browser width;\n * `page` resolves an implicit root width and auto inline margins against the\n * PDF content box. Defaults to `source`.\n */\n layoutContext?: LayoutContext;\n /** Isolated viewport used for media queries and responsive layout. */\n viewport?: ViewportOptions;\n /** Unsupported-CSS policy; defaults to `error` for strict mode and `warn` otherwise. */\n unsupportedCss?: UnsupportedCssPolicy;\n /** Unsupported SVG policy. Defaults to `error`. */\n fallback?: FallbackPolicy;\n /** Optional bridge from live canvas content to validated SVG. */\n canvasToSvg?: CanvasToSvg;\n /** Fallback when `canvasToSvg` returns `null`. Defaults to `error`. */\n canvasFallback?: CanvasFallbackPolicy;\n /** Flattens open Shadow DOM into the snapshot. Defaults to `false`. */\n includeShadowDom?: boolean;\n /** Base URL for relative resources. Defaults to the source document URL. */\n baseUrl?: string | URL;\n /** Failed-resource policy. Defaults to `error`. */\n resourcePolicy?: \"error\" | \"omit\";\n /** Resolver for protected, virtual, or otherwise unavailable resources. */\n resourceResolver?: ResourceResolver;\n /** Selector-driven page-break overrides. */\n pageBreak?: PageBreakRules;\n /** PDF information dictionary fields. */\n metadata?: PdfMetadata;\n /** Preserves PDF link annotations unless explicitly set to `false`. */\n enableLinks?: boolean;\n /**\n * Rejects the caller at snapshot and render boundaries when aborted.\n * An already-running synchronous WASM render cannot be preempted.\n */\n signal?: AbortSignal;\n /** Receives coarse phase-boundary progress, not per-page render progress. */\n onProgress?: (progress: RenderProgress) => void;\n}\n\n/** Configuration whose lifetime matches an explicit renderer instance. */\nexport interface RendererInit {\n /** Execution backend. Defaults to `worker`. */\n execution?: \"worker\" | \"main\";\n /** WASM asset override for deployments that cannot serve package-relative assets. */\n wasmUrl?: string | URL;\n /** Embeddable TrueType fonts registered once for every render. */\n fonts?: readonly FontRegistration[];\n}\n\n/** Embeddable TrueType font registered in a renderer-owned WASM context. */\nexport interface FontRegistration {\n /** CSS family name used during font resolution. */\n family: string;\n /** Complete TrueType font bytes, copied into the native context. */\n data: ArrayBuffer | Uint8Array;\n /** CSS font weight. Defaults to `400`. */\n weight?: number | \"normal\" | \"bold\";\n /** CSS font style. Defaults to `normal`. */\n style?: \"normal\" | \"italic\";\n}\n\n/** Page settings accepted through the html2pdf.js-compatible `jsPDF` option. */\nexport interface CompatJsPdfOptions {\n /** Unit shared by custom page geometry and margins. */\n unit?: LengthUnit;\n /** Named or custom page format forwarded to the modern page contract. */\n format?: PageFormat;\n /** Page orientation forwarded to the modern page contract. */\n orientation?: PageOrientation;\n}\n\n/** Page-break settings accepted by the html2pdf.js compatibility layer. */\nexport interface CompatPageBreakOptions {\n /** Compatibility modes. Defaults to `css` and `legacy`. */\n mode?: \"css\" | \"legacy\" | \"avoid-all\" | readonly (\"css\" | \"legacy\" | \"avoid-all\")[];\n /** Selectors forced to begin on a new page. */\n before?: string | readonly string[];\n /** Selectors forced to end the current page. */\n after?: string | readonly string[];\n /** Selectors whose contents should avoid internal fragmentation. */\n avoid?: string | readonly string[];\n}\n\n/** Options supported by the PDF-oriented html2pdf.js compatibility layer. */\nexport interface Html2PdfOptions {\n /** Page margins in html2pdf.js order. */\n margin?: Margin;\n /** Filename used by `save` when no method argument is supplied. */\n filename?: string;\n /** Preserves links unless explicitly disabled. */\n enableLinks?: boolean;\n /** Compatibility pagination rules. */\n pagebreak?: CompatPageBreakOptions;\n /** Compatibility page geometry. */\n jsPDF?: CompatJsPdfOptions;\n /** Unsupported because this renderer does not use an html2canvas pipeline. */\n html2canvas?: never;\n /** Unsupported because PDF pages are not encoded as raster images. */\n image?: never;\n}\n\n/** Output encodings supported by compatibility `output` methods. */\nexport type PdfOutputType =\n | \"arraybuffer\"\n | \"blob\"\n | \"bloburl\"\n | \"bloburi\"\n | \"datauristring\"\n | \"dataurlstring\";\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG","sourcesContent":["/**\n * Public configuration and callback contracts for the browser wrapper.\n *\n * @packageDocumentation\n */\n\n/** A structural ref accepted without making React a runtime dependency. */\nexport type RefLike<T> = { readonly current: T | null };\n\n/**\n * Input accepted by the snapshot boundary.\n *\n * @remarks\n * Mounted elements and refs preserve computed styles and live browser state;\n * strings are evaluated in an inert document.\n */\nexport type HtmlSource = string | Element | RefLike<Element>;\n\n/** Units used for custom page dimensions and margins. */\nexport type LengthUnit = \"pt\" | \"px\" | \"mm\" | \"cm\" | \"in\";\n\n/** Named physical page sizes or a custom `[width, height]` in the selected unit. */\nexport type PageFormat = \"a4\" | \"letter\" | readonly [width: number, height: number];\n\n/** Orientation applied after resolving the page format. */\nexport type PageOrientation = \"portrait\" | \"landscape\";\n\n/**\n * Layout and CSS support profile.\n *\n * @remarks\n * `document` favors stable paged reports. `web` enables the broader browser\n * layout profile. `strict` uses that broader profile and rejects unsupported\n * CSS by default.\n */\nexport type CssProfile = \"document\" | \"web\" | \"strict\";\n\n/** Media environment used while resolving styles and media queries. */\nexport type MediaType = \"screen\" | \"print\";\n\n/** Containing block used for the snapshotted root element. */\nexport type LayoutContext = \"source\" | \"page\";\n\n/** Action taken when an authored CSS property is outside the selected profile. */\nexport type UnsupportedCssPolicy = \"warn\" | \"error\" | \"ignore\";\n\n/** Policy for SVG subtrees that cannot remain native PDF vectors. */\nexport type FallbackPolicy = \"error\" | \"rasterize-subtree\";\n\n/** Policy used when a canvas-to-SVG adapter intentionally returns `null`. */\nexport type CanvasFallbackPolicy = \"error\" | \"rasterize\";\n\n/** Complete SVG returned by a canvas adapter. */\nexport type CanvasSvgSource = string | Blob | SVGSVGElement;\n\n/** Context passed to a canvas-to-SVG adapter. */\nexport interface CanvasToSvgRequest {\n /** Original live canvas, suitable for chart-library export APIs. */\n canvas: HTMLCanvasElement;\n /** Stable snapshot path used to identify failures and fallbacks. */\n nodePath: string;\n /** Rendered canvas width in CSS pixels. */\n cssWidth: number;\n /** Rendered canvas height in CSS pixels. */\n cssHeight: number;\n /** Backing bitmap width. */\n bitmapWidth: number;\n /** Backing bitmap height. */\n bitmapHeight: number;\n}\n\n/**\n * Replaces a live canvas with vector SVG when the source library can export it.\n *\n * @remarks\n * Returning `null` delegates to `canvasFallback`. Throwing or returning\n * malformed SVG produces `CanvasToSvgError`.\n */\nexport type CanvasToSvg = (\n request: CanvasToSvgRequest,\n) => CanvasSvgSource | null | Promise<CanvasSvgSource | null>;\n\n/** Deterministic viewport used for responsive layout and media queries. */\nexport interface ViewportOptions {\n /** Viewport width in CSS pixels. Values below one are clamped. */\n width: number;\n /** Viewport height in CSS pixels. Values below one are clamped. */\n height: number;\n}\n\n/**\n * Page margins in the selected page unit.\n *\n * @remarks\n * Four values use html2pdf.js order `[top, left, bottom, right]`, not CSS\n * shorthand order. Two values mean `[vertical, horizontal]`.\n */\nexport type Margin =\n | number\n | readonly [vertical: number, horizontal: number]\n | readonly [top: number, left: number, bottom: number, right: number];\n\n/** Explicit page geometry. Supplying this overrides captured `@page` geometry. */\nexport interface PageOptions {\n /** Page size. Defaults to `a4`. */\n format?: PageFormat;\n /** Page orientation. Defaults to `portrait`. */\n orientation?: PageOrientation;\n /** Unit for custom dimensions and margins. Defaults to `pt`. */\n unit?: LengthUnit;\n /** Page margins. Defaults to zero on every edge. */\n margin?: Margin;\n}\n\n/** Coarse rendering phases reported at stable cancellation boundaries. */\nexport type RenderPhase = \"snapshot\" | \"wasm\" | \"complete\";\n\n/** Progress notification for a rendering phase. */\nexport interface RenderProgress {\n /** Phase producing this notification. */\n phase: RenderPhase;\n /** Completed work units within the phase. */\n completed: number;\n /** Total work units within the phase. */\n total: number;\n}\n\n/** Structured warning or error produced without losing successful PDF output. */\nexport interface Diagnostic {\n /** Stable machine-readable identifier. */\n code: string;\n /** Diagnostic severity assigned by the snapshot or native renderer. */\n severity: \"warning\" | \"error\";\n /** Human-readable explanation. */\n message: string;\n /** CSS property associated with the diagnostic, when applicable. */\n property?: string;\n /** Stable snapshot path to the affected node, when available. */\n nodePath?: string;\n /** Pipeline phase that produced the diagnostic. */\n phase?: \"snapshot\" | \"parse\" | \"cascade\" | \"computed\" | \"layout\" | \"fragmentation\" | \"paint\" | \"pdf\";\n /** Fallback that preserved output despite the unsupported input. */\n fallback?: string;\n}\n\n/** Resource requested while materializing a self-contained snapshot. */\nexport interface ResourceRequest {\n /** Resource class. Fonts are registered on `createRenderer` instead. */\n kind: \"image\" | \"stylesheet\";\n /** Absolute URL resolved against `baseUrl` or the source document. */\n url: URL;\n}\n\n/**\n * Resolves resources that cannot be fetched directly by the browser snapshot.\n *\n * @remarks\n * For stylesheets, a string is CSS source. For images, a string is a data URL\n * or replacement URL. `null` leaves the request unresolved and applies\n * `resourcePolicy`.\n */\nexport type ResourceResolver = (request: ResourceRequest) => Blob | string | null | Promise<Blob | string | null>;\n\n/** Selector-driven pagination overrides compatible with html2pdf.js workflows. */\nexport interface PageBreakRules {\n /** Selectors forced to begin on a new page. */\n before?: string | readonly string[];\n /** Selectors forced to end the current page. */\n after?: string | readonly string[];\n /** Selectors whose contents should avoid internal fragmentation. */\n avoid?: string | readonly string[];\n /** Applies `break-inside: avoid` to every element. */\n avoidAll?: boolean;\n /** Honors the legacy `.html2pdf__page-break` marker. */\n legacy?: boolean;\n}\n\n/** PDF information dictionary fields written by the native renderer. */\nexport interface PdfMetadata {\n /** Document title. */\n title?: string;\n /** Document author. */\n author?: string;\n /** Document subject. */\n subject?: string;\n /** Search keywords, joined when supplied as an array. */\n keywords?: string | readonly string[];\n /** Application or service that created the document. */\n creator?: string;\n}\n\n/** Options applied to one HTML snapshot and PDF render. */\nexport interface RenderOptions {\n /** Explicit page geometry; captured `@page` rules are used when omitted. */\n page?: PageOptions;\n /**\n * Promotes unsupported snapshot CSS to errors without selecting the `web`\n * layout profile. An explicit `unsupportedCss` policy takes precedence.\n */\n strict?: boolean;\n /** Layout profile. Defaults to `document`. */\n cssProfile?: CssProfile;\n /** Media environment used for style resolution. Defaults to `screen`. */\n mediaType?: MediaType;\n /**\n * Root layout context. `source` preserves the mounted browser width;\n * `page` resolves an implicit root width and auto inline margins against the\n * PDF content box. Defaults to `source`.\n */\n layoutContext?: LayoutContext;\n /** Isolated viewport used for media queries and responsive layout. */\n viewport?: ViewportOptions;\n /** Unsupported-CSS policy; defaults to `error` for strict mode and `warn` otherwise. */\n unsupportedCss?: UnsupportedCssPolicy;\n /** Unsupported SVG policy. Defaults to `error`. */\n fallback?: FallbackPolicy;\n /** Optional bridge from live canvas content to validated SVG. */\n canvasToSvg?: CanvasToSvg;\n /** Fallback when `canvasToSvg` returns `null`. Defaults to `error`. */\n canvasFallback?: CanvasFallbackPolicy;\n /** Flattens open Shadow DOM into the snapshot. Defaults to `false`. */\n includeShadowDom?: boolean;\n /** Base URL for relative resources. Defaults to the source document URL. */\n baseUrl?: string | URL;\n /** Failed-resource policy. Defaults to `error`. */\n resourcePolicy?: \"error\" | \"omit\";\n /** Resolver for protected, virtual, or otherwise unavailable resources. */\n resourceResolver?: ResourceResolver;\n /** Selector-driven page-break overrides. */\n pageBreak?: PageBreakRules;\n /** PDF information dictionary fields. */\n metadata?: PdfMetadata;\n /** Preserves HTTP(S), mail, telephone, and FTP annotations unless explicitly set to `false`. */\n enableLinks?: boolean;\n /**\n * Rejects the caller at snapshot and render boundaries when aborted.\n * An already-running synchronous WASM render cannot be preempted.\n */\n signal?: AbortSignal;\n /** Receives coarse phase-boundary progress, not per-page render progress. */\n onProgress?: (progress: RenderProgress) => void;\n}\n\n/** Configuration whose lifetime matches an explicit renderer instance. */\nexport interface RendererInit {\n /** Execution backend. Defaults to `worker`. */\n execution?: \"worker\" | \"main\";\n /** WASM asset override for deployments that cannot serve package-relative assets. */\n wasmUrl?: string | URL;\n /** Embeddable TrueType fonts registered once for every render. */\n fonts?: readonly FontRegistration[];\n}\n\n/** Embeddable TrueType font registered in a renderer-owned WASM context. */\nexport interface FontRegistration {\n /** CSS family name used during font resolution. */\n family: string;\n /** Complete TrueType font bytes, copied into the native context. */\n data: ArrayBuffer | Uint8Array;\n /** CSS font weight. Defaults to `400`. */\n weight?: number | \"normal\" | \"bold\";\n /** CSS font style. Defaults to `normal`. */\n style?: \"normal\" | \"italic\";\n}\n\n/** Page settings accepted through the html2pdf.js-compatible `jsPDF` option. */\nexport interface CompatJsPdfOptions {\n /** Unit shared by custom page geometry and margins. */\n unit?: LengthUnit;\n /** Named or custom page format forwarded to the modern page contract. */\n format?: PageFormat;\n /** Page orientation forwarded to the modern page contract. */\n orientation?: PageOrientation;\n}\n\n/** Page-break settings accepted by the html2pdf.js compatibility layer. */\nexport interface CompatPageBreakOptions {\n /** Compatibility modes. Defaults to `css` and `legacy`. */\n mode?: \"css\" | \"legacy\" | \"avoid-all\" | readonly (\"css\" | \"legacy\" | \"avoid-all\")[];\n /** Selectors forced to begin on a new page. */\n before?: string | readonly string[];\n /** Selectors forced to end the current page. */\n after?: string | readonly string[];\n /** Selectors whose contents should avoid internal fragmentation. */\n avoid?: string | readonly string[];\n}\n\n/** Options supported by the PDF-oriented html2pdf.js compatibility layer. */\nexport interface Html2PdfOptions {\n /** Page margins in html2pdf.js order. */\n margin?: Margin;\n /** Filename used by `save` when no method argument is supplied. */\n filename?: string;\n /** Preserves HTTP(S), mail, telephone, and FTP links unless explicitly disabled. */\n enableLinks?: boolean;\n /** Compatibility pagination rules. */\n pagebreak?: CompatPageBreakOptions;\n /** Compatibility page geometry. */\n jsPDF?: CompatJsPdfOptions;\n /** Unsupported because this renderer does not use an html2canvas pipeline. */\n html2canvas?: never;\n /** Unsupported because PDF pages are not encoded as raster images. */\n image?: never;\n}\n\n/** Output encodings supported by compatibility `output` methods. */\nexport type PdfOutputType =\n | \"arraybuffer\"\n | \"blob\"\n | \"bloburl\"\n | \"bloburi\"\n | \"datauristring\"\n | \"dataurlstring\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imggion/html2realpdf",
3
- "version": "0.1.13",
3
+ "version": "0.1.14-rc2",
4
4
  "description": "Browser-first HTML to real, selectable PDF rendering powered by Zig and WebAssembly",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: html2realpdf
3
- description: Integrate and troubleshoot @imggion/html2realpdf in browser TypeScript or JavaScript projects. Use when rendering HTML strings, DOM elements, or React-compatible refs to selectable PDFs; configuring pages, resources, fonts, SVG or canvas output; previewing, downloading, or exporting PDFs; inspecting diagnostics; or migrating supported html2pdf.js chains.
3
+ description: Integrate and troubleshoot @imggion/html2realpdf in browser TypeScript or JavaScript projects. Use when rendering HTML strings, DOM elements, or React-compatible refs to selectable PDFs; designing production HTML and CSS templates; configuring deterministic A4 layouts, pagination, cards, tables, legends, resources, fonts, SVG, or canvas output; diagnosing clipped content, blank pages, or alignment issues; previewing, downloading, or exporting PDFs; inspecting diagnostics; or migrating supported html2pdf.js chains.
4
4
  ---
5
5
 
6
6
  # Use html2realpdf
@@ -45,6 +45,237 @@ try {
45
45
  Treat four-value margins as `[top, left, bottom, right]`, matching the
46
46
  html2pdf.js compatibility API rather than CSS shorthand order.
47
47
 
48
+ ## Author production report templates
49
+
50
+ Define one page geometry contract. Prefer `page.margin` for application-owned
51
+ reports, then size the rendered root against the resulting content box. Do not
52
+ also add equivalent `@page` margins and root padding.
53
+
54
+ ```ts
55
+ import { renderPdf, type RenderOptions } from "@imggion/html2realpdf";
56
+ const reportOptions: RenderOptions = {
57
+ page: { format: "a4", unit: "mm", margin: [12, 13, 12, 13] },
58
+ cssProfile: "web",
59
+ mediaType: "print",
60
+ layoutContext: "page",
61
+ viewport: { width: 1200, height: 1600 },
62
+ pageBreak: { avoid: [".pdf-atomic"], legacy: false },
63
+ fallback: "error",
64
+ };
65
+ const pdf = await renderPdf(document.querySelector("#report")!, reportOptions);
66
+ ```
67
+
68
+ For A4 with 13 mm left and right margins, the content box is 184 mm wide. A
69
+ root width of `100%` is usually sufficient; use the explicit maximum only when
70
+ the template must remain independent of its host page.
71
+
72
+ ```html
73
+ <main id="report" class="pdf-document">
74
+ <header class="pdf-header">
75
+ <img class="pdf-logo" src="/brand/logo.svg" alt="Example Company" />
76
+ <div><p class="pdf-eyebrow">Assessment report</p><h1>Candidate name</h1></div>
77
+ </header>
78
+ <section class="pdf-section">
79
+ <h2 class="pdf-keep-with-next">Profile</h2>
80
+ <dl class="pdf-metadata-grid">
81
+ <div><dt>Role</dt><dd>Product Designer</dd></div>
82
+ <div><dt>Interview date</dt><dd>28 July 2026</dd></div>
83
+ </dl>
84
+ </section>
85
+ <section class="pdf-section">
86
+ <h2 class="pdf-keep-with-next">Summary</h2>
87
+ <article class="pdf-card pdf-atomic">
88
+ <h3>Key finding</h3>
89
+ <p>Keep short, related content together inside a bounded card.</p>
90
+ </article>
91
+ </section>
92
+ </main>
93
+ ```
94
+
95
+ ```css
96
+ @media print {
97
+ .pdf-document, .pdf-document * { box-sizing: border-box; }
98
+ .pdf-document {
99
+ width: 100%;
100
+ max-width: 184mm;
101
+ margin: 0 auto;
102
+ color: #172033;
103
+ background: #fff;
104
+ font-family: Inter, Arial, sans-serif;
105
+ font-size: 10pt;
106
+ line-height: 1.45;
107
+ }
108
+ .pdf-header {
109
+ display: flex;
110
+ align-items: center;
111
+ gap: 8mm;
112
+ padding-bottom: 6mm;
113
+ border-bottom: 0.3mm solid #d8dee9;
114
+ }
115
+ .pdf-logo { display: block; width: 30mm; height: auto; }
116
+ .pdf-section { margin-top: 8mm; }
117
+ .pdf-section > :first-child { margin-top: 0; }
118
+ .pdf-section > :last-child { margin-bottom: 0; }
119
+ .pdf-metadata-grid {
120
+ display: grid;
121
+ grid-template-columns: repeat(2, minmax(0, 1fr));
122
+ gap: 4mm 8mm;
123
+ margin: 0;
124
+ }
125
+ .pdf-metadata-grid > div { min-width: 0; }
126
+ .pdf-metadata-grid dt { color: #667085; font-size: 8.5pt; }
127
+ .pdf-metadata-grid dd { margin: 1mm 0 0; overflow-wrap: anywhere; }
128
+ }
129
+ ```
130
+
131
+ Use a mounted `Element` rather than an HTML string when the template depends
132
+ on computed styles, pseudo-elements, responsive rules, live form values, or
133
+ canvas state.
134
+
135
+ ### Compose pagination deliberately
136
+
137
+ Use a small set of named pagination primitives instead of applying avoidance
138
+ to every container.
139
+
140
+ ```css
141
+ .pdf-flow { break-inside: auto; page-break-inside: auto; }
142
+ .pdf-atomic { break-inside: avoid; page-break-inside: avoid; }
143
+ .pdf-keep-with-next { break-after: avoid; page-break-after: avoid; }
144
+ .pdf-break-before { break-before: page; page-break-before: always; }
145
+ ```
146
+
147
+ - Apply `.pdf-atomic` only to content known to fit on one page. Let long prose,
148
+ lists, and tables fragment normally.
149
+ - Keep a heading with the following block, but do not combine adjacent
150
+ `break-after` and `break-before` rules for the same boundary.
151
+ - Prefer authored CSS plus narrow `pageBreak.avoid` selectors. Do not use
152
+ `avoidAll: true` or broad selectors such as every `div` in production.
153
+ - Use one explicit page-break strategy. Do not insert empty spacer elements or
154
+ mutate the DOM after measuring page positions.
155
+
156
+ ### Keep cards intact
157
+
158
+ Use semantic, bounded cards and give every painted surface an explicit
159
+ background.
160
+
161
+ ```css
162
+ .pdf-card {
163
+ padding: 5mm;
164
+ border: 0.3mm solid #d8dee9;
165
+ border-radius: 3mm;
166
+ background-color: #fff;
167
+ }
168
+ .pdf-card > :first-child { margin-top: 0; }
169
+ .pdf-card > :last-child { margin-bottom: 0; }
170
+ ```
171
+
172
+ If a card can grow beyond one page, remove `.pdf-atomic`, allow the content to
173
+ flow, and avoid clipping overflow on its wrapper.
174
+
175
+ ### Render tables predictably
176
+
177
+ Use semantic tables, declare column tracks explicitly, and keep cell widths
178
+ consistent across every row.
179
+
180
+ ```html
181
+ <div class="pdf-table-frame">
182
+ <table class="pdf-table">
183
+ <colgroup><col class="pdf-col-label" /><col /><col class="pdf-col-indicator" /></colgroup>
184
+ <thead><tr><th>Competency</th><th>Evidence</th><th>Level</th></tr></thead>
185
+ <tbody>
186
+ <tr>
187
+ <th scope="row">Collaboration</th>
188
+ <td>Concise evidence that may wrap onto multiple lines.</td>
189
+ <td class="pdf-indicator-cell">
190
+ <span class="pdf-level"><span class="pdf-dot pdf-dot-good"></span>High</span>
191
+ </td>
192
+ </tr>
193
+ </tbody>
194
+ </table>
195
+ </div>
196
+ ```
197
+
198
+ ```css
199
+ .pdf-table-frame { border: 0.3mm solid #d8dee9; border-radius: 3mm; }
200
+ .pdf-table {
201
+ width: 100%;
202
+ border-collapse: collapse;
203
+ table-layout: fixed;
204
+ }
205
+ .pdf-col-label { width: 26%; }
206
+ .pdf-col-indicator { width: 24mm; }
207
+ .pdf-table th, .pdf-table td {
208
+ padding: 3mm;
209
+ border-bottom: 0.3mm solid #e8ecf2;
210
+ text-align: left;
211
+ vertical-align: top;
212
+ overflow-wrap: anywhere;
213
+ }
214
+ .pdf-table thead, .pdf-table tr {
215
+ break-inside: avoid;
216
+ page-break-inside: avoid;
217
+ }
218
+ .pdf-table tbody tr:nth-child(odd) { background-color: #fff; }
219
+ .pdf-table tbody tr:nth-child(even) { background-color: #f7f9fc; }
220
+ .pdf-indicator-cell { text-align: right; white-space: nowrap; }
221
+ ```
222
+
223
+ Let the table and `tbody` fragment while keeping individual rows intact. Add
224
+ `.pdf-atomic` to the frame only when the application can prove the complete
225
+ table fits on one page, using measured or bounded row heights. For long tables,
226
+ do not set `overflow: hidden` on the frame; clipping conflicts with
227
+ fragmentation. Explicitly paint both odd and even row states so pagination does
228
+ not depend on a transparent inherited surface.
229
+
230
+ ### Align legends, badges, and indicators
231
+
232
+ Use flex alignment and fixed geometry. Avoid baseline nudges, negative margins,
233
+ and transforms such as `translateY`.
234
+
235
+ ```css
236
+ .pdf-level, .pdf-legend-item {
237
+ display: inline-flex;
238
+ align-items: center;
239
+ gap: 1.5mm;
240
+ min-height: 5mm;
241
+ line-height: 1.2;
242
+ vertical-align: middle;
243
+ }
244
+ .pdf-dot {
245
+ display: inline-block;
246
+ flex: 0 0 3mm;
247
+ width: 3mm;
248
+ height: 3mm;
249
+ border-radius: 50%;
250
+ }
251
+ .pdf-dot-good { background-color: #16865c; }
252
+ ```
253
+
254
+ ### Avoid fragile PDF CSS
255
+
256
+ - Do not simulate a page with fixed heights such as `min-height: 940px`.
257
+ - Do not use `margin-top: auto`, empty blocks, or absolute positioning as a
258
+ pagination mechanism.
259
+ - Do not duplicate margins across `page.margin`, `@page`, and root padding.
260
+ - Do not put `overflow: hidden` on content that may fragment across pages.
261
+ - Do not use `line-height: 0`, transforms, or negative offsets to align icons.
262
+ - Scope report styles below `.pdf-document`; avoid host-wide `body` rules when
263
+ rendering a mounted fragment.
264
+ - Do not inject a complete `<html>` document into a generic `div`. Mount the
265
+ report subtree or pass a self-contained HTML string intentionally.
266
+
267
+ ### Validate production output
268
+
269
+ - Build with the production bundler and verify Worker and WASM asset loading.
270
+ - Inspect diagnostics and fail on unsupported layout when fidelity matters.
271
+ - Confirm text selection, links, and embedded fonts in the generated PDF.
272
+ - Test empty, short, and long data, including a table that spans pages and a
273
+ paragraph or list crossing a page boundary.
274
+ - Inspect first, continuation, and final pages for repeated headers, clipped
275
+ borders, blank pages, and row or legend alignment.
276
+ - Render with the same viewport, media type, fonts, and chart export strategy
277
+ used in production.
278
+
48
279
  ## Configuration reference
49
280
 
50
281
  Use these tables as the quick option reference. Treat the package's generated