@qrcommunication/gigapdf-lib 0.17.0 → 0.19.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 +43 -0
- package/README.md +11 -4
- package/dist/index.cjs +79 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +63 -3
- package/dist/index.d.ts +63 -3
- package/dist/index.js +79 -3
- package/dist/index.js.map +1 -1
- package/gigapdf.wasm +0 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -76,6 +76,18 @@ declare class GigaPdfEngine {
|
|
|
76
76
|
rtfToPdf(rtf: string): Uint8Array;
|
|
77
77
|
/** Office (DOCX/ODT/PPTX/XLSX/ODS) → PDF, auto-detected. Empty array if unrecognized. */
|
|
78
78
|
officeToPdf(office: Uint8Array): Uint8Array;
|
|
79
|
+
/**
|
|
80
|
+
* Write a host-built grid (`pages[rows][cells]`) to an `.xlsx` workbook — one
|
|
81
|
+
* sheet per page — with the engine's native spreadsheet writer (no
|
|
82
|
+
* third-party library). Supply your own table reconstruction and still emit
|
|
83
|
+
* Office output. `sheetNames` (index-aligned to `grids`) overrides the default
|
|
84
|
+
* `Page <n>` titles; a missing/empty name falls back to the default.
|
|
85
|
+
* {@link gridsToOds} is the OpenDocument (`.ods`) counterpart.
|
|
86
|
+
*/
|
|
87
|
+
gridsToXlsx(grids: string[][][], sheetNames?: string[]): Uint8Array;
|
|
88
|
+
/** Write a host-built grid (`pages[rows][cells]`) to an `.ods` spreadsheet
|
|
89
|
+
* (optional `sheetNames`, default `Page <n>`). */
|
|
90
|
+
gridsToOds(grids: string[][][], sheetNames?: string[]): Uint8Array;
|
|
79
91
|
fontCatalog(): FontInfo[];
|
|
80
92
|
/** Google Fonts CSS2 URL for a family/weight/italic (host fetches it). */
|
|
81
93
|
fontRequestUrl(family: string, weight?: number, italic?: boolean): string;
|
|
@@ -188,7 +200,11 @@ interface FontInfo {
|
|
|
188
200
|
interface EmbeddedFont {
|
|
189
201
|
/** The `/BaseFont` name (may carry a `ABCDEF+` subset prefix). */
|
|
190
202
|
baseFont: string;
|
|
191
|
-
/**
|
|
203
|
+
/**
|
|
204
|
+
* Embedded program format. `truetype` (glyf) and a full OpenType `cff`
|
|
205
|
+
* (`OTTO`) re-embed directly via {@link GigaPdfDoc.embedFont}; bare `cff`
|
|
206
|
+
* (Type1C) and `type1` are read-only here.
|
|
207
|
+
*/
|
|
192
208
|
format: "truetype" | "cff" | "type1";
|
|
193
209
|
}
|
|
194
210
|
interface Box {
|
|
@@ -280,6 +296,11 @@ interface OutlineEntry {
|
|
|
280
296
|
title: string;
|
|
281
297
|
page?: number;
|
|
282
298
|
}
|
|
299
|
+
/** A named destination from {@link GigaPdfDoc.namedDests}: a name → page anchor. */
|
|
300
|
+
interface NamedDest {
|
|
301
|
+
name: string;
|
|
302
|
+
page: number;
|
|
303
|
+
}
|
|
283
304
|
/** An optional-content layer (calque): toggle `visible`/`locked` to persist in the PDF. */
|
|
284
305
|
interface LayerInfo {
|
|
285
306
|
id: number;
|
|
@@ -331,6 +352,12 @@ declare class GigaPdfDoc {
|
|
|
331
352
|
/** OCR a (scanned) page → words with PDF-space boxes. `scale` ≥ 2 for small text. */
|
|
332
353
|
ocr(page: number, scale?: number): OcrWord[];
|
|
333
354
|
ocrText(page: number, scale?: number): string;
|
|
355
|
+
/**
|
|
356
|
+
* Replace text run `index` on `page` with `text`. Font-aware: works with
|
|
357
|
+
* **any** font — a run set in an embedded Type0/Identity-H face (TrueType or
|
|
358
|
+
* OpenType-CFF) is re-encoded through that font's char→glyph map; base-14 and
|
|
359
|
+
* simple fonts use WinAnsi. Returns `false` if the run/page doesn't exist.
|
|
360
|
+
*/
|
|
334
361
|
replaceText(page: number, index: number, text: string): boolean;
|
|
335
362
|
removeElement(page: number, index: number): boolean;
|
|
336
363
|
moveElement(page: number, index: number, dx: number, dy: number): boolean;
|
|
@@ -403,7 +430,23 @@ declare class GigaPdfDoc {
|
|
|
403
430
|
/** A page's size (points) and `/Rotate` (0/90/180/270). */
|
|
404
431
|
pageInfo(page: number): PageInfo;
|
|
405
432
|
renderPage(page: number, scale?: number): Uint8Array;
|
|
406
|
-
|
|
433
|
+
/**
|
|
434
|
+
* Embed an outline font program as a Type0 font and return its object number
|
|
435
|
+
* (pass to {@link addText} / re-encoded by {@link replaceText}). Accepts
|
|
436
|
+
* **any** font file — glyf **TrueType** (`.ttf`) or **OpenType-CFF**
|
|
437
|
+
* (`.otf`/`OTTO`), flavour auto-detected — so `font` may be a Google Font the
|
|
438
|
+
* host fetched, an `.otf` you supply, or a face pulled out of a document with
|
|
439
|
+
* {@link extractFont}. Returns 0 on a malformed/unsupported program.
|
|
440
|
+
*/
|
|
441
|
+
embedFont(family: string, font: Uint8Array): number;
|
|
442
|
+
/**
|
|
443
|
+
* Draw real, selectable text at `(x, y)` (PDF points, origin bottom-left) in a
|
|
444
|
+
* font embedded with {@link embedFont} (`fontObj`). Works with **any** embedded
|
|
445
|
+
* face — glyf TrueType or OpenType-CFF — encoding each character through the
|
|
446
|
+
* font's char→glyph map (Identity-H, 2-byte glyph ids). `rgb` is packed
|
|
447
|
+
* `0xRRGGBB`; `rotationDeg` rotates CCW about `(x, y)`. For a built-in base-14
|
|
448
|
+
* family with no embedding, use {@link addStandardText}.
|
|
449
|
+
*/
|
|
407
450
|
addText(page: number, x: number, y: number, size: number, text: string, fontObj: number, rgb?: number, opacity?: number, rotationDeg?: number): boolean;
|
|
408
451
|
/**
|
|
409
452
|
* Draw `text` at `(x, y)` in a built-in **base-14 standard font** (`fontName`,
|
|
@@ -524,6 +567,23 @@ declare class GigaPdfDoc {
|
|
|
524
567
|
links(page: number): LinkInfo[];
|
|
525
568
|
addUriLink(page: number, x0: number, y0: number, x1: number, y1: number, uri: string): boolean;
|
|
526
569
|
addGotoLink(page: number, x0: number, y0: number, x1: number, y1: number, targetPage: number): boolean;
|
|
570
|
+
/**
|
|
571
|
+
* Register a named destination `name` → `targetPage` (a whole-page `/Fit`
|
|
572
|
+
* view) in the catalog. Links and bookmarks can then jump by name via
|
|
573
|
+
* {@link addGotoLinkNamed}; because resolution goes through the catalog (not a
|
|
574
|
+
* frozen page number), the anchor survives page extraction/split as long as
|
|
575
|
+
* its page is kept. Re-using a `name` overwrites its target.
|
|
576
|
+
*/
|
|
577
|
+
addNamedDest(name: string, targetPage: number): boolean;
|
|
578
|
+
/** The catalog's named destinations as `{name, page}` pairs. */
|
|
579
|
+
namedDests(): NamedDest[];
|
|
580
|
+
/**
|
|
581
|
+
* Add an internal hyperlink over a rectangle that jumps to the named
|
|
582
|
+
* destination `name` (define it with {@link addNamedDest}). Unlike
|
|
583
|
+
* {@link addGotoLink} (an explicit page), this stores `/Dest /name`, keeping
|
|
584
|
+
* cross-references intact through split/extract.
|
|
585
|
+
*/
|
|
586
|
+
addGotoLinkNamed(page: number, x0: number, y0: number, x1: number, y1: number, name: string): boolean;
|
|
527
587
|
layers(): LayerInfo[];
|
|
528
588
|
/** Create a new (visible, unlocked) layer; returns its id (0 on error). */
|
|
529
589
|
addLayer(name: string): number;
|
|
@@ -577,4 +637,4 @@ declare class GigaPdfDoc {
|
|
|
577
637
|
}): boolean;
|
|
578
638
|
}
|
|
579
639
|
|
|
580
|
-
export { type AnnotationInfo, type Box, type Element, type EmbeddedFont, type FieldInfo, type FieldKind, type FieldStyle, type FontInfo, GigaPdfDoc, GigaPdfEngine, type HtmlFont, type HtmlFontRequest, type HtmlMargins, type HtmlRenderOptions, type LayerInfo, type LinkInfo, type OcrWord, type OutlineEntry, type PageInfo, type RadioOption, type SearchHit, type SignP12Options, type TextLine, type TextRunInfo };
|
|
640
|
+
export { type AnnotationInfo, type Box, type Element, type EmbeddedFont, type FieldInfo, type FieldKind, type FieldStyle, type FontInfo, GigaPdfDoc, GigaPdfEngine, type HtmlFont, type HtmlFontRequest, type HtmlMargins, type HtmlRenderOptions, type LayerInfo, type LinkInfo, type NamedDest, type OcrWord, type OutlineEntry, type PageInfo, type RadioOption, type SearchHit, type SignP12Options, type TextLine, type TextRunInfo };
|
package/dist/index.d.ts
CHANGED
|
@@ -76,6 +76,18 @@ declare class GigaPdfEngine {
|
|
|
76
76
|
rtfToPdf(rtf: string): Uint8Array;
|
|
77
77
|
/** Office (DOCX/ODT/PPTX/XLSX/ODS) → PDF, auto-detected. Empty array if unrecognized. */
|
|
78
78
|
officeToPdf(office: Uint8Array): Uint8Array;
|
|
79
|
+
/**
|
|
80
|
+
* Write a host-built grid (`pages[rows][cells]`) to an `.xlsx` workbook — one
|
|
81
|
+
* sheet per page — with the engine's native spreadsheet writer (no
|
|
82
|
+
* third-party library). Supply your own table reconstruction and still emit
|
|
83
|
+
* Office output. `sheetNames` (index-aligned to `grids`) overrides the default
|
|
84
|
+
* `Page <n>` titles; a missing/empty name falls back to the default.
|
|
85
|
+
* {@link gridsToOds} is the OpenDocument (`.ods`) counterpart.
|
|
86
|
+
*/
|
|
87
|
+
gridsToXlsx(grids: string[][][], sheetNames?: string[]): Uint8Array;
|
|
88
|
+
/** Write a host-built grid (`pages[rows][cells]`) to an `.ods` spreadsheet
|
|
89
|
+
* (optional `sheetNames`, default `Page <n>`). */
|
|
90
|
+
gridsToOds(grids: string[][][], sheetNames?: string[]): Uint8Array;
|
|
79
91
|
fontCatalog(): FontInfo[];
|
|
80
92
|
/** Google Fonts CSS2 URL for a family/weight/italic (host fetches it). */
|
|
81
93
|
fontRequestUrl(family: string, weight?: number, italic?: boolean): string;
|
|
@@ -188,7 +200,11 @@ interface FontInfo {
|
|
|
188
200
|
interface EmbeddedFont {
|
|
189
201
|
/** The `/BaseFont` name (may carry a `ABCDEF+` subset prefix). */
|
|
190
202
|
baseFont: string;
|
|
191
|
-
/**
|
|
203
|
+
/**
|
|
204
|
+
* Embedded program format. `truetype` (glyf) and a full OpenType `cff`
|
|
205
|
+
* (`OTTO`) re-embed directly via {@link GigaPdfDoc.embedFont}; bare `cff`
|
|
206
|
+
* (Type1C) and `type1` are read-only here.
|
|
207
|
+
*/
|
|
192
208
|
format: "truetype" | "cff" | "type1";
|
|
193
209
|
}
|
|
194
210
|
interface Box {
|
|
@@ -280,6 +296,11 @@ interface OutlineEntry {
|
|
|
280
296
|
title: string;
|
|
281
297
|
page?: number;
|
|
282
298
|
}
|
|
299
|
+
/** A named destination from {@link GigaPdfDoc.namedDests}: a name → page anchor. */
|
|
300
|
+
interface NamedDest {
|
|
301
|
+
name: string;
|
|
302
|
+
page: number;
|
|
303
|
+
}
|
|
283
304
|
/** An optional-content layer (calque): toggle `visible`/`locked` to persist in the PDF. */
|
|
284
305
|
interface LayerInfo {
|
|
285
306
|
id: number;
|
|
@@ -331,6 +352,12 @@ declare class GigaPdfDoc {
|
|
|
331
352
|
/** OCR a (scanned) page → words with PDF-space boxes. `scale` ≥ 2 for small text. */
|
|
332
353
|
ocr(page: number, scale?: number): OcrWord[];
|
|
333
354
|
ocrText(page: number, scale?: number): string;
|
|
355
|
+
/**
|
|
356
|
+
* Replace text run `index` on `page` with `text`. Font-aware: works with
|
|
357
|
+
* **any** font — a run set in an embedded Type0/Identity-H face (TrueType or
|
|
358
|
+
* OpenType-CFF) is re-encoded through that font's char→glyph map; base-14 and
|
|
359
|
+
* simple fonts use WinAnsi. Returns `false` if the run/page doesn't exist.
|
|
360
|
+
*/
|
|
334
361
|
replaceText(page: number, index: number, text: string): boolean;
|
|
335
362
|
removeElement(page: number, index: number): boolean;
|
|
336
363
|
moveElement(page: number, index: number, dx: number, dy: number): boolean;
|
|
@@ -403,7 +430,23 @@ declare class GigaPdfDoc {
|
|
|
403
430
|
/** A page's size (points) and `/Rotate` (0/90/180/270). */
|
|
404
431
|
pageInfo(page: number): PageInfo;
|
|
405
432
|
renderPage(page: number, scale?: number): Uint8Array;
|
|
406
|
-
|
|
433
|
+
/**
|
|
434
|
+
* Embed an outline font program as a Type0 font and return its object number
|
|
435
|
+
* (pass to {@link addText} / re-encoded by {@link replaceText}). Accepts
|
|
436
|
+
* **any** font file — glyf **TrueType** (`.ttf`) or **OpenType-CFF**
|
|
437
|
+
* (`.otf`/`OTTO`), flavour auto-detected — so `font` may be a Google Font the
|
|
438
|
+
* host fetched, an `.otf` you supply, or a face pulled out of a document with
|
|
439
|
+
* {@link extractFont}. Returns 0 on a malformed/unsupported program.
|
|
440
|
+
*/
|
|
441
|
+
embedFont(family: string, font: Uint8Array): number;
|
|
442
|
+
/**
|
|
443
|
+
* Draw real, selectable text at `(x, y)` (PDF points, origin bottom-left) in a
|
|
444
|
+
* font embedded with {@link embedFont} (`fontObj`). Works with **any** embedded
|
|
445
|
+
* face — glyf TrueType or OpenType-CFF — encoding each character through the
|
|
446
|
+
* font's char→glyph map (Identity-H, 2-byte glyph ids). `rgb` is packed
|
|
447
|
+
* `0xRRGGBB`; `rotationDeg` rotates CCW about `(x, y)`. For a built-in base-14
|
|
448
|
+
* family with no embedding, use {@link addStandardText}.
|
|
449
|
+
*/
|
|
407
450
|
addText(page: number, x: number, y: number, size: number, text: string, fontObj: number, rgb?: number, opacity?: number, rotationDeg?: number): boolean;
|
|
408
451
|
/**
|
|
409
452
|
* Draw `text` at `(x, y)` in a built-in **base-14 standard font** (`fontName`,
|
|
@@ -524,6 +567,23 @@ declare class GigaPdfDoc {
|
|
|
524
567
|
links(page: number): LinkInfo[];
|
|
525
568
|
addUriLink(page: number, x0: number, y0: number, x1: number, y1: number, uri: string): boolean;
|
|
526
569
|
addGotoLink(page: number, x0: number, y0: number, x1: number, y1: number, targetPage: number): boolean;
|
|
570
|
+
/**
|
|
571
|
+
* Register a named destination `name` → `targetPage` (a whole-page `/Fit`
|
|
572
|
+
* view) in the catalog. Links and bookmarks can then jump by name via
|
|
573
|
+
* {@link addGotoLinkNamed}; because resolution goes through the catalog (not a
|
|
574
|
+
* frozen page number), the anchor survives page extraction/split as long as
|
|
575
|
+
* its page is kept. Re-using a `name` overwrites its target.
|
|
576
|
+
*/
|
|
577
|
+
addNamedDest(name: string, targetPage: number): boolean;
|
|
578
|
+
/** The catalog's named destinations as `{name, page}` pairs. */
|
|
579
|
+
namedDests(): NamedDest[];
|
|
580
|
+
/**
|
|
581
|
+
* Add an internal hyperlink over a rectangle that jumps to the named
|
|
582
|
+
* destination `name` (define it with {@link addNamedDest}). Unlike
|
|
583
|
+
* {@link addGotoLink} (an explicit page), this stores `/Dest /name`, keeping
|
|
584
|
+
* cross-references intact through split/extract.
|
|
585
|
+
*/
|
|
586
|
+
addGotoLinkNamed(page: number, x0: number, y0: number, x1: number, y1: number, name: string): boolean;
|
|
527
587
|
layers(): LayerInfo[];
|
|
528
588
|
/** Create a new (visible, unlocked) layer; returns its id (0 on error). */
|
|
529
589
|
addLayer(name: string): number;
|
|
@@ -577,4 +637,4 @@ declare class GigaPdfDoc {
|
|
|
577
637
|
}): boolean;
|
|
578
638
|
}
|
|
579
639
|
|
|
580
|
-
export { type AnnotationInfo, type Box, type Element, type EmbeddedFont, type FieldInfo, type FieldKind, type FieldStyle, type FontInfo, GigaPdfDoc, GigaPdfEngine, type HtmlFont, type HtmlFontRequest, type HtmlMargins, type HtmlRenderOptions, type LayerInfo, type LinkInfo, type OcrWord, type OutlineEntry, type PageInfo, type RadioOption, type SearchHit, type SignP12Options, type TextLine, type TextRunInfo };
|
|
640
|
+
export { type AnnotationInfo, type Box, type Element, type EmbeddedFont, type FieldInfo, type FieldKind, type FieldStyle, type FontInfo, GigaPdfDoc, GigaPdfEngine, type HtmlFont, type HtmlFontRequest, type HtmlMargins, type HtmlRenderOptions, type LayerInfo, type LinkInfo, type NamedDest, type OcrWord, type OutlineEntry, type PageInfo, type RadioOption, type SearchHit, type SignP12Options, type TextLine, type TextRunInfo };
|
package/dist/index.js
CHANGED
|
@@ -173,6 +173,34 @@ var GigaPdfEngine = class _GigaPdfEngine {
|
|
|
173
173
|
(p, l) => this._buffer((o) => this.ex.gp_office_to_pdf(p, l, o))
|
|
174
174
|
);
|
|
175
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Write a host-built grid (`pages[rows][cells]`) to an `.xlsx` workbook — one
|
|
178
|
+
* sheet per page — with the engine's native spreadsheet writer (no
|
|
179
|
+
* third-party library). Supply your own table reconstruction and still emit
|
|
180
|
+
* Office output. `sheetNames` (index-aligned to `grids`) overrides the default
|
|
181
|
+
* `Page <n>` titles; a missing/empty name falls back to the default.
|
|
182
|
+
* {@link gridsToOds} is the OpenDocument (`.ods`) counterpart.
|
|
183
|
+
*/
|
|
184
|
+
gridsToXlsx(grids, sheetNames = []) {
|
|
185
|
+
return this._withStr(
|
|
186
|
+
JSON.stringify(grids),
|
|
187
|
+
(gp, gl) => this._withStr(
|
|
188
|
+
JSON.stringify(sheetNames),
|
|
189
|
+
(np, nl) => this._buffer((o) => this.ex.gp_grids_to_xlsx(gp, gl, np, nl, o))
|
|
190
|
+
)
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
/** Write a host-built grid (`pages[rows][cells]`) to an `.ods` spreadsheet
|
|
194
|
+
* (optional `sheetNames`, default `Page <n>`). */
|
|
195
|
+
gridsToOds(grids, sheetNames = []) {
|
|
196
|
+
return this._withStr(
|
|
197
|
+
JSON.stringify(grids),
|
|
198
|
+
(gp, gl) => this._withStr(
|
|
199
|
+
JSON.stringify(sheetNames),
|
|
200
|
+
(np, nl) => this._buffer((o) => this.ex.gp_grids_to_ods(gp, gl, np, nl, o))
|
|
201
|
+
)
|
|
202
|
+
);
|
|
203
|
+
}
|
|
176
204
|
// ── fonts (catalog / Google Fonts URL — the host performs the fetch) ───────
|
|
177
205
|
fontCatalog() {
|
|
178
206
|
return this._json((o) => this.ex.gp_font_catalog_json(o));
|
|
@@ -422,6 +450,12 @@ var GigaPdfDoc = class {
|
|
|
422
450
|
return this.g._str((o) => this.ex().gp_ocr_text(this.h, page, scale, o));
|
|
423
451
|
}
|
|
424
452
|
// editing
|
|
453
|
+
/**
|
|
454
|
+
* Replace text run `index` on `page` with `text`. Font-aware: works with
|
|
455
|
+
* **any** font — a run set in an embedded Type0/Identity-H face (TrueType or
|
|
456
|
+
* OpenType-CFF) is re-encoded through that font's char→glyph map; base-14 and
|
|
457
|
+
* simple fonts use WinAnsi. Returns `false` if the run/page doesn't exist.
|
|
458
|
+
*/
|
|
425
459
|
replaceText(page, index, text) {
|
|
426
460
|
return this.g._withStr(text, (p, l) => this.ex().gp_replace_text(this.h, page, index, p, l)) === 0;
|
|
427
461
|
}
|
|
@@ -625,17 +659,33 @@ var GigaPdfDoc = class {
|
|
|
625
659
|
renderPage(page, scale = 1) {
|
|
626
660
|
return this.g._buffer((o) => this.ex().gp_render_page(this.h, page, scale, o));
|
|
627
661
|
}
|
|
628
|
-
// fonts — embed a downloaded
|
|
629
|
-
|
|
662
|
+
// fonts — embed a downloaded font, then add real selectable text
|
|
663
|
+
/**
|
|
664
|
+
* Embed an outline font program as a Type0 font and return its object number
|
|
665
|
+
* (pass to {@link addText} / re-encoded by {@link replaceText}). Accepts
|
|
666
|
+
* **any** font file — glyf **TrueType** (`.ttf`) or **OpenType-CFF**
|
|
667
|
+
* (`.otf`/`OTTO`), flavour auto-detected — so `font` may be a Google Font the
|
|
668
|
+
* host fetched, an `.otf` you supply, or a face pulled out of a document with
|
|
669
|
+
* {@link extractFont}. Returns 0 on a malformed/unsupported program.
|
|
670
|
+
*/
|
|
671
|
+
embedFont(family, font) {
|
|
630
672
|
const b = enc.encode(family);
|
|
631
673
|
const famPtr = this.g._toWasm(b);
|
|
632
674
|
const obj = this.g._withBytes(
|
|
633
|
-
|
|
675
|
+
font,
|
|
634
676
|
(p, l) => this.ex().gp_embed_font(this.h, famPtr, b.length, p, l)
|
|
635
677
|
);
|
|
636
678
|
this.g._free(famPtr, b.length);
|
|
637
679
|
return obj;
|
|
638
680
|
}
|
|
681
|
+
/**
|
|
682
|
+
* Draw real, selectable text at `(x, y)` (PDF points, origin bottom-left) in a
|
|
683
|
+
* font embedded with {@link embedFont} (`fontObj`). Works with **any** embedded
|
|
684
|
+
* face — glyf TrueType or OpenType-CFF — encoding each character through the
|
|
685
|
+
* font's char→glyph map (Identity-H, 2-byte glyph ids). `rgb` is packed
|
|
686
|
+
* `0xRRGGBB`; `rotationDeg` rotates CCW about `(x, y)`. For a built-in base-14
|
|
687
|
+
* family with no embedding, use {@link addStandardText}.
|
|
688
|
+
*/
|
|
639
689
|
addText(page, x, y, size, text, fontObj, rgb = 0, opacity = 1, rotationDeg = 0) {
|
|
640
690
|
return this.g._withStr(
|
|
641
691
|
text,
|
|
@@ -997,6 +1047,32 @@ var GigaPdfDoc = class {
|
|
|
997
1047
|
addGotoLink(page, x0, y0, x1, y1, targetPage) {
|
|
998
1048
|
return this.ex().gp_add_goto_link(this.h, page, x0, y0, x1, y1, targetPage) === 0;
|
|
999
1049
|
}
|
|
1050
|
+
/**
|
|
1051
|
+
* Register a named destination `name` → `targetPage` (a whole-page `/Fit`
|
|
1052
|
+
* view) in the catalog. Links and bookmarks can then jump by name via
|
|
1053
|
+
* {@link addGotoLinkNamed}; because resolution goes through the catalog (not a
|
|
1054
|
+
* frozen page number), the anchor survives page extraction/split as long as
|
|
1055
|
+
* its page is kept. Re-using a `name` overwrites its target.
|
|
1056
|
+
*/
|
|
1057
|
+
addNamedDest(name, targetPage) {
|
|
1058
|
+
return this.g._withStr(name, (p, l) => this.ex().gp_add_named_dest(this.h, p, l, targetPage)) === 0;
|
|
1059
|
+
}
|
|
1060
|
+
/** The catalog's named destinations as `{name, page}` pairs. */
|
|
1061
|
+
namedDests() {
|
|
1062
|
+
return this.g._json((o) => this.ex().gp_named_dests_json(this.h, o));
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Add an internal hyperlink over a rectangle that jumps to the named
|
|
1066
|
+
* destination `name` (define it with {@link addNamedDest}). Unlike
|
|
1067
|
+
* {@link addGotoLink} (an explicit page), this stores `/Dest /name`, keeping
|
|
1068
|
+
* cross-references intact through split/extract.
|
|
1069
|
+
*/
|
|
1070
|
+
addGotoLinkNamed(page, x0, y0, x1, y1, name) {
|
|
1071
|
+
return this.g._withStr(
|
|
1072
|
+
name,
|
|
1073
|
+
(p, l) => this.ex().gp_add_goto_link_named(this.h, page, x0, y0, x1, y1, p, l)
|
|
1074
|
+
) === 0;
|
|
1075
|
+
}
|
|
1000
1076
|
// optional-content layers (calques): list + show/hide + lock/unlock + remove
|
|
1001
1077
|
layers() {
|
|
1002
1078
|
return this.g._json((o) => this.ex().gp_layers_json(this.h, o));
|