@qrcommunication/gigapdf-lib 0.64.0 → 0.65.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 +14 -0
- package/dist/index.cjs +26 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/gigapdf.wasm +0 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -103,6 +103,23 @@ declare class GigaPdfEngine {
|
|
|
103
103
|
* a recognized Office container, `[]` if it needs no host fonts.
|
|
104
104
|
*/
|
|
105
105
|
officeNeededFonts(office: Uint8Array): HtmlFontRequest[] | null;
|
|
106
|
+
/**
|
|
107
|
+
* Phase 2 for {@link officeNeededFonts} — render an Office container to PDF with
|
|
108
|
+
* the host-fetched `fonts` embedded, so families the container **references but
|
|
109
|
+
* doesn't embed** (reported by {@link officeNeededFonts}) lay out with the right
|
|
110
|
+
* metrics (e.g. Carlito for a Calibri reference) instead of drifting onto the
|
|
111
|
+
* bundled fallback. Faces the container embeds itself win on conflict, so an
|
|
112
|
+
* empty `fonts` array yields exactly {@link officeToPdf}'s output. Empty array
|
|
113
|
+
* if the bytes are not a recognized Office container.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* const reqs = giga.officeNeededFonts(docx); // phase 1: what to fetch
|
|
117
|
+
* const fonts = await Promise.all( // host fetches each url → TTF
|
|
118
|
+
* (reqs ?? []).map(async (r) => ({ ...r, ttf: await fetchTtf(r.url) }))
|
|
119
|
+
* );
|
|
120
|
+
* const pdf = giga.officeToPdfWith(docx, fonts); // phase 2: render with them
|
|
121
|
+
*/
|
|
122
|
+
officeToPdfWith(office: Uint8Array, fonts?: HtmlFont[]): Uint8Array;
|
|
106
123
|
/**
|
|
107
124
|
* Image (PNG/JPEG/GIF/WebP/AVIF) → one-page PDF, format auto-detected: the
|
|
108
125
|
* image is centred and scaled to fit on an A4 portrait page. PNG/JPEG embed
|
package/dist/index.d.ts
CHANGED
|
@@ -103,6 +103,23 @@ declare class GigaPdfEngine {
|
|
|
103
103
|
* a recognized Office container, `[]` if it needs no host fonts.
|
|
104
104
|
*/
|
|
105
105
|
officeNeededFonts(office: Uint8Array): HtmlFontRequest[] | null;
|
|
106
|
+
/**
|
|
107
|
+
* Phase 2 for {@link officeNeededFonts} — render an Office container to PDF with
|
|
108
|
+
* the host-fetched `fonts` embedded, so families the container **references but
|
|
109
|
+
* doesn't embed** (reported by {@link officeNeededFonts}) lay out with the right
|
|
110
|
+
* metrics (e.g. Carlito for a Calibri reference) instead of drifting onto the
|
|
111
|
+
* bundled fallback. Faces the container embeds itself win on conflict, so an
|
|
112
|
+
* empty `fonts` array yields exactly {@link officeToPdf}'s output. Empty array
|
|
113
|
+
* if the bytes are not a recognized Office container.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* const reqs = giga.officeNeededFonts(docx); // phase 1: what to fetch
|
|
117
|
+
* const fonts = await Promise.all( // host fetches each url → TTF
|
|
118
|
+
* (reqs ?? []).map(async (r) => ({ ...r, ttf: await fetchTtf(r.url) }))
|
|
119
|
+
* );
|
|
120
|
+
* const pdf = giga.officeToPdfWith(docx, fonts); // phase 2: render with them
|
|
121
|
+
*/
|
|
122
|
+
officeToPdfWith(office: Uint8Array, fonts?: HtmlFont[]): Uint8Array;
|
|
106
123
|
/**
|
|
107
124
|
* Image (PNG/JPEG/GIF/WebP/AVIF) → one-page PDF, format auto-detected: the
|
|
108
125
|
* image is centred and scaled to fit on an A4 portrait page. PNG/JPEG embed
|
package/dist/index.js
CHANGED
|
@@ -256,6 +256,32 @@ var GigaPdfEngine = class _GigaPdfEngine {
|
|
|
256
256
|
(p, l) => this._jsonOrNull((o) => this.ex.gp_office_needed_fonts(p, l, o))
|
|
257
257
|
);
|
|
258
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* Phase 2 for {@link officeNeededFonts} — render an Office container to PDF with
|
|
261
|
+
* the host-fetched `fonts` embedded, so families the container **references but
|
|
262
|
+
* doesn't embed** (reported by {@link officeNeededFonts}) lay out with the right
|
|
263
|
+
* metrics (e.g. Carlito for a Calibri reference) instead of drifting onto the
|
|
264
|
+
* bundled fallback. Faces the container embeds itself win on conflict, so an
|
|
265
|
+
* empty `fonts` array yields exactly {@link officeToPdf}'s output. Empty array
|
|
266
|
+
* if the bytes are not a recognized Office container.
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* const reqs = giga.officeNeededFonts(docx); // phase 1: what to fetch
|
|
270
|
+
* const fonts = await Promise.all( // host fetches each url → TTF
|
|
271
|
+
* (reqs ?? []).map(async (r) => ({ ...r, ttf: await fetchTtf(r.url) }))
|
|
272
|
+
* );
|
|
273
|
+
* const pdf = giga.officeToPdfWith(docx, fonts); // phase 2: render with them
|
|
274
|
+
*/
|
|
275
|
+
officeToPdfWith(office, fonts = []) {
|
|
276
|
+
const blob = packHtmlFonts(fonts);
|
|
277
|
+
return this._withBytes(
|
|
278
|
+
office,
|
|
279
|
+
(op, ol) => this._withBytes(
|
|
280
|
+
blob,
|
|
281
|
+
(fp, fl) => this._buffer((o) => this.ex.gp_office_to_pdf_with_fonts(op, ol, fp, fl, o))
|
|
282
|
+
)
|
|
283
|
+
);
|
|
284
|
+
}
|
|
259
285
|
/**
|
|
260
286
|
* Image (PNG/JPEG/GIF/WebP/AVIF) → one-page PDF, format auto-detected: the
|
|
261
287
|
* image is centred and scaled to fit on an A4 portrait page. PNG/JPEG embed
|