@formepdf/core 0.10.5 → 0.11.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/dist/index.d.ts CHANGED
@@ -95,6 +95,22 @@ export interface RenderDocumentOptions {
95
95
  }
96
96
  export declare function renderDocument(element: ReactElement, options?: RenderDocumentOptions): Promise<Uint8Array>;
97
97
  export declare function renderDocumentWithLayout(element: ReactElement, options?: RenderDocumentOptions): Promise<RenderWithLayoutResult>;
98
+ /**
99
+ * Render a pre-serialized document object (from `serialize()`) to PDF,
100
+ * resolving font sources (file paths, byte arrays) and HTTP image URLs
101
+ * first.
102
+ *
103
+ * Use this when you have a serialized doc (e.g. from a non-react
104
+ * adapter that calls its own `serialize()`) and need font/image
105
+ * resolution without going through the React element-based
106
+ * `renderDocument()`. The browser and worker entries export the same
107
+ * pair.
108
+ */
109
+ export declare function renderSerializedDoc(doc: Record<string, unknown>, options?: RenderDocumentOptions): Promise<Uint8Array>;
110
+ /**
111
+ * Like `renderSerializedDoc` but also returns layout info for overlays.
112
+ */
113
+ export declare function renderSerializedDocWithLayout(doc: Record<string, unknown>, options?: RenderDocumentOptions): Promise<RenderWithLayoutResult>;
98
114
  export declare function renderTemplate(templateJson: string, dataJson: string): Promise<Uint8Array>;
99
115
  export declare function renderTemplateWithLayout(templateJson: string, dataJson: string): Promise<RenderWithLayoutResult>;
100
116
  export declare function certifyPdf(pdfBytes: Uint8Array, config: CertificationConfig): Promise<Uint8Array>;
package/dist/index.js CHANGED
@@ -64,6 +64,26 @@ export async function renderPdfWithLayout(json) {
64
64
  export async function renderDocument(element, options) {
65
65
  const { serialize } = await import('@formepdf/react');
66
66
  const doc = serialize(element);
67
+ return renderSerializedDoc(doc, options);
68
+ }
69
+ export async function renderDocumentWithLayout(element, options) {
70
+ const { serialize } = await import('@formepdf/react');
71
+ const doc = serialize(element);
72
+ return renderSerializedDocWithLayout(doc, options);
73
+ }
74
+ // ── Serialized document rendering ────────────────────────────────────
75
+ /**
76
+ * Render a pre-serialized document object (from `serialize()`) to PDF,
77
+ * resolving font sources (file paths, byte arrays) and HTTP image URLs
78
+ * first.
79
+ *
80
+ * Use this when you have a serialized doc (e.g. from a non-react
81
+ * adapter that calls its own `serialize()`) and need font/image
82
+ * resolution without going through the React element-based
83
+ * `renderDocument()`. The browser and worker entries export the same
84
+ * pair.
85
+ */
86
+ export async function renderSerializedDoc(doc, options) {
67
87
  if (options?.embedData !== undefined) {
68
88
  doc.embeddedData = JSON.stringify(options.embedData);
69
89
  }
@@ -73,9 +93,10 @@ export async function renderDocument(element, options) {
73
93
  await Promise.all([resolveFonts(doc), resolveImages(doc)]);
74
94
  return renderPdf(JSON.stringify(doc));
75
95
  }
76
- export async function renderDocumentWithLayout(element, options) {
77
- const { serialize } = await import('@formepdf/react');
78
- const doc = serialize(element);
96
+ /**
97
+ * Like `renderSerializedDoc` but also returns layout info for overlays.
98
+ */
99
+ export async function renderSerializedDocWithLayout(doc, options) {
79
100
  if (options?.embedData !== undefined) {
80
101
  doc.embeddedData = JSON.stringify(options.embedData);
81
102
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formepdf/core",
3
- "version": "0.10.5",
3
+ "version": "0.11.0",
4
4
  "description": "WASM-powered PDF rendering engine for Forme",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -59,7 +59,7 @@
59
59
  "prepublishOnly": "npm run build && ./scripts/assert-tarball.sh"
60
60
  },
61
61
  "dependencies": {
62
- "@formepdf/react": "0.10.5"
62
+ "@formepdf/react": "0.11.0"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "react": "^18 || ^19"
package/pkg/forme_bg.wasm CHANGED
Binary file
package/pkg/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "forme-pdf",
3
3
  "type": "module",
4
4
  "description": "A page-native PDF rendering engine. Layout INTO pages, not onto an infinite canvas.",
5
- "version": "0.10.5",
5
+ "version": "0.11.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
Binary file
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "forme-pdf",
3
3
  "description": "A page-native PDF rendering engine. Layout INTO pages, not onto an infinite canvas.",
4
- "version": "0.10.5",
4
+ "version": "0.11.0",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
Binary file
@@ -2,7 +2,7 @@
2
2
  "name": "forme-pdf",
3
3
  "type": "module",
4
4
  "description": "A page-native PDF rendering engine. Layout INTO pages, not onto an infinite canvas.",
5
- "version": "0.10.5",
5
+ "version": "0.11.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",