@qrcommunication/gigapdf-lib 0.109.0 → 0.110.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 +66 -0
- package/dist/index.cjs +57 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -2
- package/dist/index.d.ts +37 -2
- package/dist/index.js +57 -2
- package/dist/index.js.map +1 -1
- package/gigapdf.wasm +0 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -374,6 +374,25 @@ declare class GigaPdfEngine {
|
|
|
374
374
|
* table. Returns `null` if the bytes contain no parseable fields.
|
|
375
375
|
*/
|
|
376
376
|
csvToModel(csv: Uint8Array): GigaDocument | null;
|
|
377
|
+
/**
|
|
378
|
+
* Lower an RTF string into the unified {@link GigaDocument} model. Routed
|
|
379
|
+
* through the rich RTF parser, so run-level styling (bold/italic/underline/
|
|
380
|
+
* strike, colour, size, family), tables, `\pict` images and `\field`
|
|
381
|
+
* hyperlinks are recovered — the inverse of {@link modelToRtf}.
|
|
382
|
+
*/
|
|
383
|
+
rtfToModel(rtf: string): GigaDocument;
|
|
384
|
+
/**
|
|
385
|
+
* Lower a plain-text string into the unified {@link GigaDocument} model: one
|
|
386
|
+
* paragraph per line (blank lines kept as empty paragraphs).
|
|
387
|
+
*/
|
|
388
|
+
txtToModel(text: string): GigaDocument;
|
|
389
|
+
/**
|
|
390
|
+
* Lower a raster image (PNG/JPEG/GIF/WebP, auto-detected) into the unified
|
|
391
|
+
* {@link GigaDocument} model — a single full-page picture block sized to the
|
|
392
|
+
* image's own aspect ratio, with the bytes interned in the model's resource
|
|
393
|
+
* table. Returns `null` if the bytes aren't a recognized image.
|
|
394
|
+
*/
|
|
395
|
+
imageToModel(image: Uint8Array): GigaDocument | null;
|
|
377
396
|
/**
|
|
378
397
|
* Apply a batch of {@link ModelOp} edits to a model and return the edited
|
|
379
398
|
* model. Ops run in order; out-of-range addresses (and any op that can't be
|
|
@@ -2316,7 +2335,8 @@ declare class GigaPdfDoc {
|
|
|
2316
2335
|
* photo while every reference to it stays intact (ISO 32000-1 §8.9). `index` is
|
|
2317
2336
|
* the **unified element index** of an image on `page`, exactly the `index`
|
|
2318
2337
|
* reported by {@link imageElements} (and accepted by {@link removeElement} /
|
|
2319
|
-
* {@link transformElement}); `data` is
|
|
2338
|
+
* {@link transformElement}); `data` is any raster the engine decodes — PNG,
|
|
2339
|
+
* JPEG, WebP, GIF, TIFF or AVIF (the same set {@link addImage} accepts).
|
|
2320
2340
|
*
|
|
2321
2341
|
* Unlike a delete-then-re-add, the image keeps its object number, **every `/Do`
|
|
2322
2342
|
* placement, and its position / scale / rotation / clip matrix** — only the
|
|
@@ -2327,7 +2347,7 @@ declare class GigaPdfDoc {
|
|
|
2327
2347
|
* drawn into the same box (transform the element first to re-fit it).
|
|
2328
2348
|
*
|
|
2329
2349
|
* Returns `false` if `page`/`index` doesn't resolve to a top-level image, or the
|
|
2330
|
-
* bytes aren't a decodable
|
|
2350
|
+
* bytes aren't a decodable raster.
|
|
2331
2351
|
*/
|
|
2332
2352
|
replaceImage(page: number, index: number, data: Uint8Array): boolean;
|
|
2333
2353
|
/**
|
|
@@ -2793,6 +2813,21 @@ declare class GigaPdfDoc {
|
|
|
2793
2813
|
format: "truetype" | "cff" | "type1";
|
|
2794
2814
|
bytes: Uint8Array;
|
|
2795
2815
|
} | null;
|
|
2816
|
+
/**
|
|
2817
|
+
* Extract an embedded font as a **browser-loadable** sfnt by (fuzzy)
|
|
2818
|
+
* `/BaseFont` name — for a host editor's `@font-face` overlay-text layer.
|
|
2819
|
+
* Unlike {@link extractFont} (raw program, for re-embedding), this always
|
|
2820
|
+
* returns bytes a browser's `FontFace`/OTS will accept, **keeping the
|
|
2821
|
+
* document's own glyphs** (no substitution): a bare CFF (Type1C) is wrapped to
|
|
2822
|
+
* OpenType with a `cmap` from its charset, and a `cmap`-less TrueType subset is
|
|
2823
|
+
* repaired with a `cmap` synthesised from the PDF's `code → Unicode` (original
|
|
2824
|
+
* `glyf` kept). `truetype`/`otf` are directly loadable; `cff`/`type1` are raw
|
|
2825
|
+
* last-resort fallbacks. `null` when nothing embedded matches.
|
|
2826
|
+
*/
|
|
2827
|
+
extractWebFont(name: string): {
|
|
2828
|
+
format: "truetype" | "otf" | "cff" | "type1";
|
|
2829
|
+
bytes: Uint8Array;
|
|
2830
|
+
} | null;
|
|
2796
2831
|
/**
|
|
2797
2832
|
* The fonts **embedded** in the document — each `{ baseFont, format }`. Pair
|
|
2798
2833
|
* with {@link extractFont} to pull a font's bytes out and re-embed them via
|
package/dist/index.d.ts
CHANGED
|
@@ -374,6 +374,25 @@ declare class GigaPdfEngine {
|
|
|
374
374
|
* table. Returns `null` if the bytes contain no parseable fields.
|
|
375
375
|
*/
|
|
376
376
|
csvToModel(csv: Uint8Array): GigaDocument | null;
|
|
377
|
+
/**
|
|
378
|
+
* Lower an RTF string into the unified {@link GigaDocument} model. Routed
|
|
379
|
+
* through the rich RTF parser, so run-level styling (bold/italic/underline/
|
|
380
|
+
* strike, colour, size, family), tables, `\pict` images and `\field`
|
|
381
|
+
* hyperlinks are recovered — the inverse of {@link modelToRtf}.
|
|
382
|
+
*/
|
|
383
|
+
rtfToModel(rtf: string): GigaDocument;
|
|
384
|
+
/**
|
|
385
|
+
* Lower a plain-text string into the unified {@link GigaDocument} model: one
|
|
386
|
+
* paragraph per line (blank lines kept as empty paragraphs).
|
|
387
|
+
*/
|
|
388
|
+
txtToModel(text: string): GigaDocument;
|
|
389
|
+
/**
|
|
390
|
+
* Lower a raster image (PNG/JPEG/GIF/WebP, auto-detected) into the unified
|
|
391
|
+
* {@link GigaDocument} model — a single full-page picture block sized to the
|
|
392
|
+
* image's own aspect ratio, with the bytes interned in the model's resource
|
|
393
|
+
* table. Returns `null` if the bytes aren't a recognized image.
|
|
394
|
+
*/
|
|
395
|
+
imageToModel(image: Uint8Array): GigaDocument | null;
|
|
377
396
|
/**
|
|
378
397
|
* Apply a batch of {@link ModelOp} edits to a model and return the edited
|
|
379
398
|
* model. Ops run in order; out-of-range addresses (and any op that can't be
|
|
@@ -2316,7 +2335,8 @@ declare class GigaPdfDoc {
|
|
|
2316
2335
|
* photo while every reference to it stays intact (ISO 32000-1 §8.9). `index` is
|
|
2317
2336
|
* the **unified element index** of an image on `page`, exactly the `index`
|
|
2318
2337
|
* reported by {@link imageElements} (and accepted by {@link removeElement} /
|
|
2319
|
-
* {@link transformElement}); `data` is
|
|
2338
|
+
* {@link transformElement}); `data` is any raster the engine decodes — PNG,
|
|
2339
|
+
* JPEG, WebP, GIF, TIFF or AVIF (the same set {@link addImage} accepts).
|
|
2320
2340
|
*
|
|
2321
2341
|
* Unlike a delete-then-re-add, the image keeps its object number, **every `/Do`
|
|
2322
2342
|
* placement, and its position / scale / rotation / clip matrix** — only the
|
|
@@ -2327,7 +2347,7 @@ declare class GigaPdfDoc {
|
|
|
2327
2347
|
* drawn into the same box (transform the element first to re-fit it).
|
|
2328
2348
|
*
|
|
2329
2349
|
* Returns `false` if `page`/`index` doesn't resolve to a top-level image, or the
|
|
2330
|
-
* bytes aren't a decodable
|
|
2350
|
+
* bytes aren't a decodable raster.
|
|
2331
2351
|
*/
|
|
2332
2352
|
replaceImage(page: number, index: number, data: Uint8Array): boolean;
|
|
2333
2353
|
/**
|
|
@@ -2793,6 +2813,21 @@ declare class GigaPdfDoc {
|
|
|
2793
2813
|
format: "truetype" | "cff" | "type1";
|
|
2794
2814
|
bytes: Uint8Array;
|
|
2795
2815
|
} | null;
|
|
2816
|
+
/**
|
|
2817
|
+
* Extract an embedded font as a **browser-loadable** sfnt by (fuzzy)
|
|
2818
|
+
* `/BaseFont` name — for a host editor's `@font-face` overlay-text layer.
|
|
2819
|
+
* Unlike {@link extractFont} (raw program, for re-embedding), this always
|
|
2820
|
+
* returns bytes a browser's `FontFace`/OTS will accept, **keeping the
|
|
2821
|
+
* document's own glyphs** (no substitution): a bare CFF (Type1C) is wrapped to
|
|
2822
|
+
* OpenType with a `cmap` from its charset, and a `cmap`-less TrueType subset is
|
|
2823
|
+
* repaired with a `cmap` synthesised from the PDF's `code → Unicode` (original
|
|
2824
|
+
* `glyf` kept). `truetype`/`otf` are directly loadable; `cff`/`type1` are raw
|
|
2825
|
+
* last-resort fallbacks. `null` when nothing embedded matches.
|
|
2826
|
+
*/
|
|
2827
|
+
extractWebFont(name: string): {
|
|
2828
|
+
format: "truetype" | "otf" | "cff" | "type1";
|
|
2829
|
+
bytes: Uint8Array;
|
|
2830
|
+
} | null;
|
|
2796
2831
|
/**
|
|
2797
2832
|
* The fonts **embedded** in the document — each `{ baseFont, format }`. Pair
|
|
2798
2833
|
* with {@link extractFont} to pull a font's bytes out and re-embed them via
|
package/dist/index.js
CHANGED
|
@@ -783,6 +783,40 @@ var GigaPdfEngine = class _GigaPdfEngine {
|
|
|
783
783
|
(p, l) => this._modelOrNull((o) => this.ex.gp_model_from_csv(p, l, o))
|
|
784
784
|
);
|
|
785
785
|
}
|
|
786
|
+
/**
|
|
787
|
+
* Lower an RTF string into the unified {@link GigaDocument} model. Routed
|
|
788
|
+
* through the rich RTF parser, so run-level styling (bold/italic/underline/
|
|
789
|
+
* strike, colour, size, family), tables, `\pict` images and `\field`
|
|
790
|
+
* hyperlinks are recovered — the inverse of {@link modelToRtf}.
|
|
791
|
+
*/
|
|
792
|
+
rtfToModel(rtf) {
|
|
793
|
+
return this._withStr(
|
|
794
|
+
rtf,
|
|
795
|
+
(p, l) => JSON.parse(this._str((o) => this.ex.gp_model_from_rtf(p, l, o)))
|
|
796
|
+
);
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* Lower a plain-text string into the unified {@link GigaDocument} model: one
|
|
800
|
+
* paragraph per line (blank lines kept as empty paragraphs).
|
|
801
|
+
*/
|
|
802
|
+
txtToModel(text) {
|
|
803
|
+
return this._withStr(
|
|
804
|
+
text,
|
|
805
|
+
(p, l) => JSON.parse(this._str((o) => this.ex.gp_model_from_txt(p, l, o)))
|
|
806
|
+
);
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Lower a raster image (PNG/JPEG/GIF/WebP, auto-detected) into the unified
|
|
810
|
+
* {@link GigaDocument} model — a single full-page picture block sized to the
|
|
811
|
+
* image's own aspect ratio, with the bytes interned in the model's resource
|
|
812
|
+
* table. Returns `null` if the bytes aren't a recognized image.
|
|
813
|
+
*/
|
|
814
|
+
imageToModel(image) {
|
|
815
|
+
return this._withBytes(
|
|
816
|
+
image,
|
|
817
|
+
(p, l) => this._modelOrNull((o) => this.ex.gp_model_from_image(p, l, o))
|
|
818
|
+
);
|
|
819
|
+
}
|
|
786
820
|
/**
|
|
787
821
|
* Apply a batch of {@link ModelOp} edits to a model and return the edited
|
|
788
822
|
* model. Ops run in order; out-of-range addresses (and any op that can't be
|
|
@@ -1616,7 +1650,8 @@ var GigaPdfDoc = class {
|
|
|
1616
1650
|
* photo while every reference to it stays intact (ISO 32000-1 §8.9). `index` is
|
|
1617
1651
|
* the **unified element index** of an image on `page`, exactly the `index`
|
|
1618
1652
|
* reported by {@link imageElements} (and accepted by {@link removeElement} /
|
|
1619
|
-
* {@link transformElement}); `data` is
|
|
1653
|
+
* {@link transformElement}); `data` is any raster the engine decodes — PNG,
|
|
1654
|
+
* JPEG, WebP, GIF, TIFF or AVIF (the same set {@link addImage} accepts).
|
|
1620
1655
|
*
|
|
1621
1656
|
* Unlike a delete-then-re-add, the image keeps its object number, **every `/Do`
|
|
1622
1657
|
* placement, and its position / scale / rotation / clip matrix** — only the
|
|
@@ -1627,7 +1662,7 @@ var GigaPdfDoc = class {
|
|
|
1627
1662
|
* drawn into the same box (transform the element first to re-fit it).
|
|
1628
1663
|
*
|
|
1629
1664
|
* Returns `false` if `page`/`index` doesn't resolve to a top-level image, or the
|
|
1630
|
-
* bytes aren't a decodable
|
|
1665
|
+
* bytes aren't a decodable raster.
|
|
1631
1666
|
*/
|
|
1632
1667
|
replaceImage(page, index, data) {
|
|
1633
1668
|
return this.g._withBytes(data, (p, l) => this.ex().gp_replace_image(this.h, page, index, p, l)) === 0;
|
|
@@ -2370,6 +2405,26 @@ var GigaPdfDoc = class {
|
|
|
2370
2405
|
const format = buf[0] === 1 ? "truetype" : buf[0] === 2 ? "cff" : "type1";
|
|
2371
2406
|
return { format, bytes: buf.subarray(1) };
|
|
2372
2407
|
}
|
|
2408
|
+
/**
|
|
2409
|
+
* Extract an embedded font as a **browser-loadable** sfnt by (fuzzy)
|
|
2410
|
+
* `/BaseFont` name — for a host editor's `@font-face` overlay-text layer.
|
|
2411
|
+
* Unlike {@link extractFont} (raw program, for re-embedding), this always
|
|
2412
|
+
* returns bytes a browser's `FontFace`/OTS will accept, **keeping the
|
|
2413
|
+
* document's own glyphs** (no substitution): a bare CFF (Type1C) is wrapped to
|
|
2414
|
+
* OpenType with a `cmap` from its charset, and a `cmap`-less TrueType subset is
|
|
2415
|
+
* repaired with a `cmap` synthesised from the PDF's `code → Unicode` (original
|
|
2416
|
+
* `glyf` kept). `truetype`/`otf` are directly loadable; `cff`/`type1` are raw
|
|
2417
|
+
* last-resort fallbacks. `null` when nothing embedded matches.
|
|
2418
|
+
*/
|
|
2419
|
+
extractWebFont(name) {
|
|
2420
|
+
const buf = this.g._withStr(
|
|
2421
|
+
name,
|
|
2422
|
+
(p, l) => this.g._buffer((o) => this.ex().gp_extract_web_font(this.h, p, l, o))
|
|
2423
|
+
);
|
|
2424
|
+
if (buf.length === 0) return null;
|
|
2425
|
+
const format = buf[0] === 1 ? "truetype" : buf[0] === 2 ? "otf" : buf[0] === 3 ? "cff" : "type1";
|
|
2426
|
+
return { format, bytes: buf.subarray(1) };
|
|
2427
|
+
}
|
|
2373
2428
|
/**
|
|
2374
2429
|
* The fonts **embedded** in the document — each `{ baseFont, format }`. Pair
|
|
2375
2430
|
* with {@link extractFont} to pull a font's bytes out and re-embed them via
|