@qrcommunication/gigapdf-lib 0.109.1 → 0.110.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/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
@@ -2794,6 +2813,21 @@ declare class GigaPdfDoc {
2794
2813
  format: "truetype" | "cff" | "type1";
2795
2814
  bytes: Uint8Array;
2796
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;
2797
2831
  /**
2798
2832
  * The fonts **embedded** in the document — each `{ baseFont, format }`. Pair
2799
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
@@ -2794,6 +2813,21 @@ declare class GigaPdfDoc {
2794
2813
  format: "truetype" | "cff" | "type1";
2795
2814
  bytes: Uint8Array;
2796
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;
2797
2831
  /**
2798
2832
  * The fonts **embedded** in the document — each `{ baseFont, format }`. Pair
2799
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
@@ -2371,6 +2405,26 @@ var GigaPdfDoc = class {
2371
2405
  const format = buf[0] === 1 ? "truetype" : buf[0] === 2 ? "cff" : "type1";
2372
2406
  return { format, bytes: buf.subarray(1) };
2373
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
+ }
2374
2428
  /**
2375
2429
  * The fonts **embedded** in the document — each `{ baseFont, format }`. Pair
2376
2430
  * with {@link extractFont} to pull a font's bytes out and re-embed them via