@qrcommunication/gigapdf-lib 0.112.0 → 0.114.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 +95 -0
- package/dist/index.cjs +65 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +116 -1
- package/dist/index.d.ts +116 -1
- package/dist/index.js +65 -0
- package/dist/index.js.map +1 -1
- package/gigapdf.wasm +0 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -524,6 +524,32 @@ interface EmbeddedFont {
|
|
|
524
524
|
*/
|
|
525
525
|
format: "truetype" | "cff" | "type1";
|
|
526
526
|
}
|
|
527
|
+
/**
|
|
528
|
+
* One embedded font **program** (from {@link GigaPdfDoc.embeddedFontsV2}) —
|
|
529
|
+
* the per-program, deduplicated sibling of {@link EmbeddedFont}. A form
|
|
530
|
+
* generator routinely embeds dozens of same-family font wrappers whose
|
|
531
|
+
* descriptors all share a handful of physical programs; where
|
|
532
|
+
* {@link GigaPdfDoc.embeddedFonts} lists one entry per *name*, this lists one
|
|
533
|
+
* entry per `/FontFile*` stream, with every name wrapped around it.
|
|
534
|
+
*/
|
|
535
|
+
interface EmbeddedFontV2 {
|
|
536
|
+
/**
|
|
537
|
+
* The program's stable content identity (first 8 hex chars of the SHA-256
|
|
538
|
+
* of the decoded bytes) — feed it to {@link GigaPdfDoc.extractWebFontById}
|
|
539
|
+
* / {@link GigaPdfDoc.webFontCoverage}. Matches
|
|
540
|
+
* {@link TextElementInfo.fontId}.
|
|
541
|
+
*/
|
|
542
|
+
fontId: string;
|
|
543
|
+
/** Embedded program format (see {@link EmbeddedFont.format}). */
|
|
544
|
+
format: "truetype" | "cff" | "type1";
|
|
545
|
+
/** Glyph count of the parsed program (`0` when it does not parse). */
|
|
546
|
+
numGlyphs: number;
|
|
547
|
+
/**
|
|
548
|
+
* The `/BaseFont` names of every wrapper font dict referencing this program
|
|
549
|
+
* (deduplicated, sorted).
|
|
550
|
+
*/
|
|
551
|
+
baseFonts: string[];
|
|
552
|
+
}
|
|
527
553
|
interface Box {
|
|
528
554
|
x: number;
|
|
529
555
|
y: number;
|
|
@@ -558,6 +584,17 @@ interface TextElementInfo {
|
|
|
558
584
|
* Empty when the run's font carried no `/BaseFont` (e.g. a Type3 font).
|
|
559
585
|
*/
|
|
560
586
|
baseFont: string;
|
|
587
|
+
/**
|
|
588
|
+
* The **physical** identity of the run's embedded font program — the first
|
|
589
|
+
* 8 hex chars of the SHA-256 of its decoded `/FontFile*` bytes, matching
|
|
590
|
+
* {@link EmbeddedFontV2.fontId}. Unlike {@link baseFont} (a *name*,
|
|
591
|
+
* ambiguous when many wrapper dicts share one program), this pins the exact
|
|
592
|
+
* program: feed it to {@link GigaPdfDoc.extractWebFontById} (with this
|
|
593
|
+
* run's {@link baseFont} as `preferWrapper`) to always get the run's own
|
|
594
|
+
* glyphs. Empty when the run's font embeds no program (base-14 /
|
|
595
|
+
* non-embedded faces, Type3).
|
|
596
|
+
*/
|
|
597
|
+
fontId?: string;
|
|
561
598
|
bold: boolean;
|
|
562
599
|
italic: boolean;
|
|
563
600
|
/** Effective glyph size in points. */
|
|
@@ -664,6 +701,12 @@ interface GigaInlineRun {
|
|
|
664
701
|
style: GigaCharStyle;
|
|
665
702
|
/** Index of the source content-stream run for in-place round-tripping, or `null`. */
|
|
666
703
|
source_index: number | null;
|
|
704
|
+
/**
|
|
705
|
+
* Every source content-stream run index this span was coalesced from (the
|
|
706
|
+
* scalar `source_index` is its first entry, kept for backward compatibility).
|
|
707
|
+
* Present since 0.114.0; older documents/readers may omit it.
|
|
708
|
+
*/
|
|
709
|
+
source_indices?: number[];
|
|
667
710
|
}
|
|
668
711
|
/** Paragraph-level formatting (mirror of `model::style::ParagraphStyle`). */
|
|
669
712
|
interface GigaParagraphStyle {
|
|
@@ -1478,6 +1521,33 @@ interface FieldInfo {
|
|
|
1478
1521
|
bounds?: [number, number, number, number];
|
|
1479
1522
|
value: string;
|
|
1480
1523
|
options: string[];
|
|
1524
|
+
/**
|
|
1525
|
+
* EVERY widget placement of this field — one per on-page widget. A field
|
|
1526
|
+
* repeated on a duplicate page has one entry per page (fill it once, it shows
|
|
1527
|
+
* on both); a radio group has one entry per button. `page`/`bounds` above are
|
|
1528
|
+
* this list's first entry (kept for backward compatibility). A host renders a
|
|
1529
|
+
* field overlay per widget so nothing is missing on a duplicate/second page.
|
|
1530
|
+
*/
|
|
1531
|
+
widgets: WidgetPlacement[];
|
|
1532
|
+
}
|
|
1533
|
+
/**
|
|
1534
|
+
* One on-page placement of a form field — a single widget annotation. See
|
|
1535
|
+
* {@link FieldInfo.widgets}.
|
|
1536
|
+
*/
|
|
1537
|
+
interface WidgetPlacement {
|
|
1538
|
+
/** 1-based page the widget sits on (from its `/P`). */
|
|
1539
|
+
page?: number;
|
|
1540
|
+
/**
|
|
1541
|
+
* Widget rectangle `[x, y, width, height]` in points, **top-left origin**
|
|
1542
|
+
* (already Y-flipped from the PDF's bottom-left `/Rect`).
|
|
1543
|
+
*/
|
|
1544
|
+
bounds?: [number, number, number, number];
|
|
1545
|
+
/**
|
|
1546
|
+
* For a button widget, its on-state export name (the non-`Off` `/AP /N` key)
|
|
1547
|
+
* — which radio button this widget is / the value stored when selected. Absent
|
|
1548
|
+
* for text and choice widgets.
|
|
1549
|
+
*/
|
|
1550
|
+
export?: string;
|
|
1481
1551
|
}
|
|
1482
1552
|
/**
|
|
1483
1553
|
* A view destination (ISO 32000-1 §12.3.2). `page` is 1-based; optional
|
|
@@ -2850,6 +2920,25 @@ declare class GigaPdfDoc {
|
|
|
2850
2920
|
format: "truetype" | "otf" | "cff" | "type1";
|
|
2851
2921
|
bytes: Uint8Array;
|
|
2852
2922
|
} | null;
|
|
2923
|
+
/**
|
|
2924
|
+
* Extract an embedded font as a **browser-loadable** sfnt by its **physical
|
|
2925
|
+
* identity** (`fontId` — the value {@link textElements} and
|
|
2926
|
+
* {@link embeddedFontsV2} report). The name-ambiguity-proof sibling of
|
|
2927
|
+
* {@link extractWebFont}: a form generator routinely embeds dozens of
|
|
2928
|
+
* same-`/BaseFont` wrappers over a handful of physical programs, each with
|
|
2929
|
+
* its own *partial* `/ToUnicode` — a name lookup can land on a homonym whose
|
|
2930
|
+
* 2-entry map drops accents the program actually carries. Resolving by
|
|
2931
|
+
* `fontId` pins the exact program, and the served `cmap` is rebuilt as the
|
|
2932
|
+
* **union of every wrapper** referencing it (explicit `/ToUnicode` entries
|
|
2933
|
+
* first — `preferWrapper`, the run's own {@link TextElementInfo.baseFont},
|
|
2934
|
+
* winning on conflict — then inferred fills). The subset is always served
|
|
2935
|
+
* as-is, never rejected for an incomplete map. `null` only when no embedded
|
|
2936
|
+
* program carries `fontId`.
|
|
2937
|
+
*/
|
|
2938
|
+
extractWebFontById(fontId: string, preferWrapper?: string): {
|
|
2939
|
+
format: "truetype" | "otf" | "cff" | "type1";
|
|
2940
|
+
bytes: Uint8Array;
|
|
2941
|
+
} | null;
|
|
2853
2942
|
/**
|
|
2854
2943
|
* The fonts **embedded** in the document — each `{ baseFont, format }`. Pair
|
|
2855
2944
|
* with {@link extractFont} to pull a font's bytes out and re-embed them via
|
|
@@ -2857,6 +2946,23 @@ declare class GigaPdfDoc {
|
|
|
2857
2946
|
* the document already carries — no external font file needed.
|
|
2858
2947
|
*/
|
|
2859
2948
|
embeddedFonts(): EmbeddedFont[];
|
|
2949
|
+
/**
|
|
2950
|
+
* The embedded fonts **deduplicated by physical program** — one
|
|
2951
|
+
* {@link EmbeddedFontV2} per `/FontFile*` stream, carrying its `fontId`,
|
|
2952
|
+
* format, glyph count and every `/BaseFont` wrapped around it. The
|
|
2953
|
+
* per-program sibling of {@link embeddedFonts} (kept intact); its `fontId`s
|
|
2954
|
+
* feed {@link extractWebFontById} / {@link webFontCoverage}. Sorted by
|
|
2955
|
+
* `fontId` for a deterministic output.
|
|
2956
|
+
*/
|
|
2957
|
+
embeddedFontsV2(): EmbeddedFontV2[];
|
|
2958
|
+
/**
|
|
2959
|
+
* The Unicode code points mapped by the `cmap` {@link extractWebFontById}
|
|
2960
|
+
* serves for `fontId` — sorted, deduplicated. Lets a host check, before
|
|
2961
|
+
* painting, whether a run's characters are covered by the served face (and
|
|
2962
|
+
* pick a fallback for the gaps). Empty when no embedded program carries
|
|
2963
|
+
* `fontId`.
|
|
2964
|
+
*/
|
|
2965
|
+
webFontCoverage(fontId: string): number[];
|
|
2860
2966
|
toText(): string;
|
|
2861
2967
|
toHtml(): string;
|
|
2862
2968
|
/**
|
|
@@ -3347,6 +3453,15 @@ declare class GigaPdfDoc {
|
|
|
3347
3453
|
fields(): FieldInfo[];
|
|
3348
3454
|
setTextField(name: string, value: string): boolean;
|
|
3349
3455
|
setCheckbox(name: string, checked: boolean): boolean;
|
|
3456
|
+
/**
|
|
3457
|
+
* Set a checkbox to a **named** appearance state — the on-state export of
|
|
3458
|
+
* one of its widgets. A multi-widget checkbox names one export per widget
|
|
3459
|
+
* (e.g. `Oui` / `non` on French CERFA forms); {@link setCheckbox} with
|
|
3460
|
+
* `true` only ever reaches the first export, this reaches any of them.
|
|
3461
|
+
* `"Off"` unchecks every widget. Returns `false` when the field or state
|
|
3462
|
+
* doesn't exist.
|
|
3463
|
+
*/
|
|
3464
|
+
setCheckboxState(name: string, state: string): boolean;
|
|
3350
3465
|
setRadio(name: string, value: string): boolean;
|
|
3351
3466
|
/** Set a choice field's selection (multi-select list boxes accept several values). */
|
|
3352
3467
|
setChoice(name: string, values: string[]): boolean;
|
|
@@ -3421,4 +3536,4 @@ declare class GigaPdfDoc {
|
|
|
3421
3536
|
regenerateFieldAppearance(name: string): boolean;
|
|
3422
3537
|
}
|
|
3423
3538
|
|
|
3424
|
-
export { type Action, type AfRelationship, type AnnotationInfo, type Attachment, type AttachmentOptions, type Bookmark, type Box, type CollectionConfig, type CollectionField, type CollectionFieldSubtype, type CollectionItem, type CollectionView, type Color, type DecodedImage, type Destination, type DocumentJavascript, type DocumentLanguage, type Element, type EmbeddedFont, type Exports, type FieldInfo, type FieldKind, type FieldStyle, type FileAttachmentIcon, type FontInfo, type GigaBlock, type GigaBlockAddr, type GigaBlockKind, type GigaBorderStyle, type GigaCellValue, type GigaCharStyle, type GigaDocument, type GigaGeneric, type GigaHeading, type GigaImageRef, type GigaInline, type GigaInlineRun, type GigaLinkTarget, type GigaList, type GigaListItem, type GigaListMarker, type GigaMergeRange, type GigaOutlineNode, type GigaPage, type GigaPageGeometry, type GigaParaPatch, type GigaParagraph, type GigaParagraphStyle, type GigaPathSeg, GigaPdfDoc, GigaPdfEngine, type GigaPlaceholder, type GigaPlaceholderRole, type GigaRect, type GigaRotation, type GigaSection, type GigaShape, type GigaSheet, type GigaSheetBlock, type GigaSheetCell, type GigaSheetRow, type GigaSlide, type GigaSlideBlock, type GigaStylePatch, type GigaTable, type GigaTableCell, type GigaTableRow, type GigaTextBox, type GradientSpec, type GradientStop, type HFAlign, type HFItem, type HFZone, type HeaderFooterAlign, type HeaderFooterSpec, type HtmlFont, type HtmlFontRequest, type HtmlMargins, type HtmlRenderOptions, type HtmlResource, type HtmlResourceNeed, type ImageElementInfo, type InfoFields, type LayerInfo, type LinkInfo, type MergePart, type ModelOp, type NamedDest, type OutlineEntry, PAGE_BOX_KINDS, PAGE_TRANSITION_STYLES, type PageBoxKind, type PageBoxes, type PageInfo, type PageLabelRange, type PageLabelStyle, type PageLayout, type PageMargins, type PageMode, type PageTransition, type PageTransitionDimension, type PageTransitionDirection, type PageTransitionMotion, type PageTransitionStyle, type PathSegment, type PdfPermissions, type PdfVersion, type RadioOption, type RunningHeaderFooter, type SearchHit, type SignLtvOptions, type SignP12Options, type SignTsaOptions, type SignatureInfo, type SignatureReport, type TextElementInfo, type TextLine, type TextRunInfo, type TextSegment, type VectorPathInfo, type ViewerPreferences, type XlsxSheet, defaultCrlGet, defaultOcspPost, defaultTsaPost };
|
|
3539
|
+
export { type Action, type AfRelationship, type AnnotationInfo, type Attachment, type AttachmentOptions, type Bookmark, type Box, type CollectionConfig, type CollectionField, type CollectionFieldSubtype, type CollectionItem, type CollectionView, type Color, type DecodedImage, type Destination, type DocumentJavascript, type DocumentLanguage, type Element, type EmbeddedFont, type EmbeddedFontV2, type Exports, type FieldInfo, type FieldKind, type FieldStyle, type FileAttachmentIcon, type FontInfo, type GigaBlock, type GigaBlockAddr, type GigaBlockKind, type GigaBorderStyle, type GigaCellValue, type GigaCharStyle, type GigaDocument, type GigaGeneric, type GigaHeading, type GigaImageRef, type GigaInline, type GigaInlineRun, type GigaLinkTarget, type GigaList, type GigaListItem, type GigaListMarker, type GigaMergeRange, type GigaOutlineNode, type GigaPage, type GigaPageGeometry, type GigaParaPatch, type GigaParagraph, type GigaParagraphStyle, type GigaPathSeg, GigaPdfDoc, GigaPdfEngine, type GigaPlaceholder, type GigaPlaceholderRole, type GigaRect, type GigaRotation, type GigaSection, type GigaShape, type GigaSheet, type GigaSheetBlock, type GigaSheetCell, type GigaSheetRow, type GigaSlide, type GigaSlideBlock, type GigaStylePatch, type GigaTable, type GigaTableCell, type GigaTableRow, type GigaTextBox, type GradientSpec, type GradientStop, type HFAlign, type HFItem, type HFZone, type HeaderFooterAlign, type HeaderFooterSpec, type HtmlFont, type HtmlFontRequest, type HtmlMargins, type HtmlRenderOptions, type HtmlResource, type HtmlResourceNeed, type ImageElementInfo, type InfoFields, type LayerInfo, type LinkInfo, type MergePart, type ModelOp, type NamedDest, type OutlineEntry, PAGE_BOX_KINDS, PAGE_TRANSITION_STYLES, type PageBoxKind, type PageBoxes, type PageInfo, type PageLabelRange, type PageLabelStyle, type PageLayout, type PageMargins, type PageMode, type PageTransition, type PageTransitionDimension, type PageTransitionDirection, type PageTransitionMotion, type PageTransitionStyle, type PathSegment, type PdfPermissions, type PdfVersion, type RadioOption, type RunningHeaderFooter, type SearchHit, type SignLtvOptions, type SignP12Options, type SignTsaOptions, type SignatureInfo, type SignatureReport, type TextElementInfo, type TextLine, type TextRunInfo, type TextSegment, type VectorPathInfo, type ViewerPreferences, type WidgetPlacement, type XlsxSheet, defaultCrlGet, defaultOcspPost, defaultTsaPost };
|
package/dist/index.d.ts
CHANGED
|
@@ -524,6 +524,32 @@ interface EmbeddedFont {
|
|
|
524
524
|
*/
|
|
525
525
|
format: "truetype" | "cff" | "type1";
|
|
526
526
|
}
|
|
527
|
+
/**
|
|
528
|
+
* One embedded font **program** (from {@link GigaPdfDoc.embeddedFontsV2}) —
|
|
529
|
+
* the per-program, deduplicated sibling of {@link EmbeddedFont}. A form
|
|
530
|
+
* generator routinely embeds dozens of same-family font wrappers whose
|
|
531
|
+
* descriptors all share a handful of physical programs; where
|
|
532
|
+
* {@link GigaPdfDoc.embeddedFonts} lists one entry per *name*, this lists one
|
|
533
|
+
* entry per `/FontFile*` stream, with every name wrapped around it.
|
|
534
|
+
*/
|
|
535
|
+
interface EmbeddedFontV2 {
|
|
536
|
+
/**
|
|
537
|
+
* The program's stable content identity (first 8 hex chars of the SHA-256
|
|
538
|
+
* of the decoded bytes) — feed it to {@link GigaPdfDoc.extractWebFontById}
|
|
539
|
+
* / {@link GigaPdfDoc.webFontCoverage}. Matches
|
|
540
|
+
* {@link TextElementInfo.fontId}.
|
|
541
|
+
*/
|
|
542
|
+
fontId: string;
|
|
543
|
+
/** Embedded program format (see {@link EmbeddedFont.format}). */
|
|
544
|
+
format: "truetype" | "cff" | "type1";
|
|
545
|
+
/** Glyph count of the parsed program (`0` when it does not parse). */
|
|
546
|
+
numGlyphs: number;
|
|
547
|
+
/**
|
|
548
|
+
* The `/BaseFont` names of every wrapper font dict referencing this program
|
|
549
|
+
* (deduplicated, sorted).
|
|
550
|
+
*/
|
|
551
|
+
baseFonts: string[];
|
|
552
|
+
}
|
|
527
553
|
interface Box {
|
|
528
554
|
x: number;
|
|
529
555
|
y: number;
|
|
@@ -558,6 +584,17 @@ interface TextElementInfo {
|
|
|
558
584
|
* Empty when the run's font carried no `/BaseFont` (e.g. a Type3 font).
|
|
559
585
|
*/
|
|
560
586
|
baseFont: string;
|
|
587
|
+
/**
|
|
588
|
+
* The **physical** identity of the run's embedded font program — the first
|
|
589
|
+
* 8 hex chars of the SHA-256 of its decoded `/FontFile*` bytes, matching
|
|
590
|
+
* {@link EmbeddedFontV2.fontId}. Unlike {@link baseFont} (a *name*,
|
|
591
|
+
* ambiguous when many wrapper dicts share one program), this pins the exact
|
|
592
|
+
* program: feed it to {@link GigaPdfDoc.extractWebFontById} (with this
|
|
593
|
+
* run's {@link baseFont} as `preferWrapper`) to always get the run's own
|
|
594
|
+
* glyphs. Empty when the run's font embeds no program (base-14 /
|
|
595
|
+
* non-embedded faces, Type3).
|
|
596
|
+
*/
|
|
597
|
+
fontId?: string;
|
|
561
598
|
bold: boolean;
|
|
562
599
|
italic: boolean;
|
|
563
600
|
/** Effective glyph size in points. */
|
|
@@ -664,6 +701,12 @@ interface GigaInlineRun {
|
|
|
664
701
|
style: GigaCharStyle;
|
|
665
702
|
/** Index of the source content-stream run for in-place round-tripping, or `null`. */
|
|
666
703
|
source_index: number | null;
|
|
704
|
+
/**
|
|
705
|
+
* Every source content-stream run index this span was coalesced from (the
|
|
706
|
+
* scalar `source_index` is its first entry, kept for backward compatibility).
|
|
707
|
+
* Present since 0.114.0; older documents/readers may omit it.
|
|
708
|
+
*/
|
|
709
|
+
source_indices?: number[];
|
|
667
710
|
}
|
|
668
711
|
/** Paragraph-level formatting (mirror of `model::style::ParagraphStyle`). */
|
|
669
712
|
interface GigaParagraphStyle {
|
|
@@ -1478,6 +1521,33 @@ interface FieldInfo {
|
|
|
1478
1521
|
bounds?: [number, number, number, number];
|
|
1479
1522
|
value: string;
|
|
1480
1523
|
options: string[];
|
|
1524
|
+
/**
|
|
1525
|
+
* EVERY widget placement of this field — one per on-page widget. A field
|
|
1526
|
+
* repeated on a duplicate page has one entry per page (fill it once, it shows
|
|
1527
|
+
* on both); a radio group has one entry per button. `page`/`bounds` above are
|
|
1528
|
+
* this list's first entry (kept for backward compatibility). A host renders a
|
|
1529
|
+
* field overlay per widget so nothing is missing on a duplicate/second page.
|
|
1530
|
+
*/
|
|
1531
|
+
widgets: WidgetPlacement[];
|
|
1532
|
+
}
|
|
1533
|
+
/**
|
|
1534
|
+
* One on-page placement of a form field — a single widget annotation. See
|
|
1535
|
+
* {@link FieldInfo.widgets}.
|
|
1536
|
+
*/
|
|
1537
|
+
interface WidgetPlacement {
|
|
1538
|
+
/** 1-based page the widget sits on (from its `/P`). */
|
|
1539
|
+
page?: number;
|
|
1540
|
+
/**
|
|
1541
|
+
* Widget rectangle `[x, y, width, height]` in points, **top-left origin**
|
|
1542
|
+
* (already Y-flipped from the PDF's bottom-left `/Rect`).
|
|
1543
|
+
*/
|
|
1544
|
+
bounds?: [number, number, number, number];
|
|
1545
|
+
/**
|
|
1546
|
+
* For a button widget, its on-state export name (the non-`Off` `/AP /N` key)
|
|
1547
|
+
* — which radio button this widget is / the value stored when selected. Absent
|
|
1548
|
+
* for text and choice widgets.
|
|
1549
|
+
*/
|
|
1550
|
+
export?: string;
|
|
1481
1551
|
}
|
|
1482
1552
|
/**
|
|
1483
1553
|
* A view destination (ISO 32000-1 §12.3.2). `page` is 1-based; optional
|
|
@@ -2850,6 +2920,25 @@ declare class GigaPdfDoc {
|
|
|
2850
2920
|
format: "truetype" | "otf" | "cff" | "type1";
|
|
2851
2921
|
bytes: Uint8Array;
|
|
2852
2922
|
} | null;
|
|
2923
|
+
/**
|
|
2924
|
+
* Extract an embedded font as a **browser-loadable** sfnt by its **physical
|
|
2925
|
+
* identity** (`fontId` — the value {@link textElements} and
|
|
2926
|
+
* {@link embeddedFontsV2} report). The name-ambiguity-proof sibling of
|
|
2927
|
+
* {@link extractWebFont}: a form generator routinely embeds dozens of
|
|
2928
|
+
* same-`/BaseFont` wrappers over a handful of physical programs, each with
|
|
2929
|
+
* its own *partial* `/ToUnicode` — a name lookup can land on a homonym whose
|
|
2930
|
+
* 2-entry map drops accents the program actually carries. Resolving by
|
|
2931
|
+
* `fontId` pins the exact program, and the served `cmap` is rebuilt as the
|
|
2932
|
+
* **union of every wrapper** referencing it (explicit `/ToUnicode` entries
|
|
2933
|
+
* first — `preferWrapper`, the run's own {@link TextElementInfo.baseFont},
|
|
2934
|
+
* winning on conflict — then inferred fills). The subset is always served
|
|
2935
|
+
* as-is, never rejected for an incomplete map. `null` only when no embedded
|
|
2936
|
+
* program carries `fontId`.
|
|
2937
|
+
*/
|
|
2938
|
+
extractWebFontById(fontId: string, preferWrapper?: string): {
|
|
2939
|
+
format: "truetype" | "otf" | "cff" | "type1";
|
|
2940
|
+
bytes: Uint8Array;
|
|
2941
|
+
} | null;
|
|
2853
2942
|
/**
|
|
2854
2943
|
* The fonts **embedded** in the document — each `{ baseFont, format }`. Pair
|
|
2855
2944
|
* with {@link extractFont} to pull a font's bytes out and re-embed them via
|
|
@@ -2857,6 +2946,23 @@ declare class GigaPdfDoc {
|
|
|
2857
2946
|
* the document already carries — no external font file needed.
|
|
2858
2947
|
*/
|
|
2859
2948
|
embeddedFonts(): EmbeddedFont[];
|
|
2949
|
+
/**
|
|
2950
|
+
* The embedded fonts **deduplicated by physical program** — one
|
|
2951
|
+
* {@link EmbeddedFontV2} per `/FontFile*` stream, carrying its `fontId`,
|
|
2952
|
+
* format, glyph count and every `/BaseFont` wrapped around it. The
|
|
2953
|
+
* per-program sibling of {@link embeddedFonts} (kept intact); its `fontId`s
|
|
2954
|
+
* feed {@link extractWebFontById} / {@link webFontCoverage}. Sorted by
|
|
2955
|
+
* `fontId` for a deterministic output.
|
|
2956
|
+
*/
|
|
2957
|
+
embeddedFontsV2(): EmbeddedFontV2[];
|
|
2958
|
+
/**
|
|
2959
|
+
* The Unicode code points mapped by the `cmap` {@link extractWebFontById}
|
|
2960
|
+
* serves for `fontId` — sorted, deduplicated. Lets a host check, before
|
|
2961
|
+
* painting, whether a run's characters are covered by the served face (and
|
|
2962
|
+
* pick a fallback for the gaps). Empty when no embedded program carries
|
|
2963
|
+
* `fontId`.
|
|
2964
|
+
*/
|
|
2965
|
+
webFontCoverage(fontId: string): number[];
|
|
2860
2966
|
toText(): string;
|
|
2861
2967
|
toHtml(): string;
|
|
2862
2968
|
/**
|
|
@@ -3347,6 +3453,15 @@ declare class GigaPdfDoc {
|
|
|
3347
3453
|
fields(): FieldInfo[];
|
|
3348
3454
|
setTextField(name: string, value: string): boolean;
|
|
3349
3455
|
setCheckbox(name: string, checked: boolean): boolean;
|
|
3456
|
+
/**
|
|
3457
|
+
* Set a checkbox to a **named** appearance state — the on-state export of
|
|
3458
|
+
* one of its widgets. A multi-widget checkbox names one export per widget
|
|
3459
|
+
* (e.g. `Oui` / `non` on French CERFA forms); {@link setCheckbox} with
|
|
3460
|
+
* `true` only ever reaches the first export, this reaches any of them.
|
|
3461
|
+
* `"Off"` unchecks every widget. Returns `false` when the field or state
|
|
3462
|
+
* doesn't exist.
|
|
3463
|
+
*/
|
|
3464
|
+
setCheckboxState(name: string, state: string): boolean;
|
|
3350
3465
|
setRadio(name: string, value: string): boolean;
|
|
3351
3466
|
/** Set a choice field's selection (multi-select list boxes accept several values). */
|
|
3352
3467
|
setChoice(name: string, values: string[]): boolean;
|
|
@@ -3421,4 +3536,4 @@ declare class GigaPdfDoc {
|
|
|
3421
3536
|
regenerateFieldAppearance(name: string): boolean;
|
|
3422
3537
|
}
|
|
3423
3538
|
|
|
3424
|
-
export { type Action, type AfRelationship, type AnnotationInfo, type Attachment, type AttachmentOptions, type Bookmark, type Box, type CollectionConfig, type CollectionField, type CollectionFieldSubtype, type CollectionItem, type CollectionView, type Color, type DecodedImage, type Destination, type DocumentJavascript, type DocumentLanguage, type Element, type EmbeddedFont, type Exports, type FieldInfo, type FieldKind, type FieldStyle, type FileAttachmentIcon, type FontInfo, type GigaBlock, type GigaBlockAddr, type GigaBlockKind, type GigaBorderStyle, type GigaCellValue, type GigaCharStyle, type GigaDocument, type GigaGeneric, type GigaHeading, type GigaImageRef, type GigaInline, type GigaInlineRun, type GigaLinkTarget, type GigaList, type GigaListItem, type GigaListMarker, type GigaMergeRange, type GigaOutlineNode, type GigaPage, type GigaPageGeometry, type GigaParaPatch, type GigaParagraph, type GigaParagraphStyle, type GigaPathSeg, GigaPdfDoc, GigaPdfEngine, type GigaPlaceholder, type GigaPlaceholderRole, type GigaRect, type GigaRotation, type GigaSection, type GigaShape, type GigaSheet, type GigaSheetBlock, type GigaSheetCell, type GigaSheetRow, type GigaSlide, type GigaSlideBlock, type GigaStylePatch, type GigaTable, type GigaTableCell, type GigaTableRow, type GigaTextBox, type GradientSpec, type GradientStop, type HFAlign, type HFItem, type HFZone, type HeaderFooterAlign, type HeaderFooterSpec, type HtmlFont, type HtmlFontRequest, type HtmlMargins, type HtmlRenderOptions, type HtmlResource, type HtmlResourceNeed, type ImageElementInfo, type InfoFields, type LayerInfo, type LinkInfo, type MergePart, type ModelOp, type NamedDest, type OutlineEntry, PAGE_BOX_KINDS, PAGE_TRANSITION_STYLES, type PageBoxKind, type PageBoxes, type PageInfo, type PageLabelRange, type PageLabelStyle, type PageLayout, type PageMargins, type PageMode, type PageTransition, type PageTransitionDimension, type PageTransitionDirection, type PageTransitionMotion, type PageTransitionStyle, type PathSegment, type PdfPermissions, type PdfVersion, type RadioOption, type RunningHeaderFooter, type SearchHit, type SignLtvOptions, type SignP12Options, type SignTsaOptions, type SignatureInfo, type SignatureReport, type TextElementInfo, type TextLine, type TextRunInfo, type TextSegment, type VectorPathInfo, type ViewerPreferences, type XlsxSheet, defaultCrlGet, defaultOcspPost, defaultTsaPost };
|
|
3539
|
+
export { type Action, type AfRelationship, type AnnotationInfo, type Attachment, type AttachmentOptions, type Bookmark, type Box, type CollectionConfig, type CollectionField, type CollectionFieldSubtype, type CollectionItem, type CollectionView, type Color, type DecodedImage, type Destination, type DocumentJavascript, type DocumentLanguage, type Element, type EmbeddedFont, type EmbeddedFontV2, type Exports, type FieldInfo, type FieldKind, type FieldStyle, type FileAttachmentIcon, type FontInfo, type GigaBlock, type GigaBlockAddr, type GigaBlockKind, type GigaBorderStyle, type GigaCellValue, type GigaCharStyle, type GigaDocument, type GigaGeneric, type GigaHeading, type GigaImageRef, type GigaInline, type GigaInlineRun, type GigaLinkTarget, type GigaList, type GigaListItem, type GigaListMarker, type GigaMergeRange, type GigaOutlineNode, type GigaPage, type GigaPageGeometry, type GigaParaPatch, type GigaParagraph, type GigaParagraphStyle, type GigaPathSeg, GigaPdfDoc, GigaPdfEngine, type GigaPlaceholder, type GigaPlaceholderRole, type GigaRect, type GigaRotation, type GigaSection, type GigaShape, type GigaSheet, type GigaSheetBlock, type GigaSheetCell, type GigaSheetRow, type GigaSlide, type GigaSlideBlock, type GigaStylePatch, type GigaTable, type GigaTableCell, type GigaTableRow, type GigaTextBox, type GradientSpec, type GradientStop, type HFAlign, type HFItem, type HFZone, type HeaderFooterAlign, type HeaderFooterSpec, type HtmlFont, type HtmlFontRequest, type HtmlMargins, type HtmlRenderOptions, type HtmlResource, type HtmlResourceNeed, type ImageElementInfo, type InfoFields, type LayerInfo, type LinkInfo, type MergePart, type ModelOp, type NamedDest, type OutlineEntry, PAGE_BOX_KINDS, PAGE_TRANSITION_STYLES, type PageBoxKind, type PageBoxes, type PageInfo, type PageLabelRange, type PageLabelStyle, type PageLayout, type PageMargins, type PageMode, type PageTransition, type PageTransitionDimension, type PageTransitionDirection, type PageTransitionMotion, type PageTransitionStyle, type PathSegment, type PdfPermissions, type PdfVersion, type RadioOption, type RunningHeaderFooter, type SearchHit, type SignLtvOptions, type SignP12Options, type SignTsaOptions, type SignatureInfo, type SignatureReport, type TextElementInfo, type TextLine, type TextRunInfo, type TextSegment, type VectorPathInfo, type ViewerPreferences, type WidgetPlacement, type XlsxSheet, defaultCrlGet, defaultOcspPost, defaultTsaPost };
|
package/dist/index.js
CHANGED
|
@@ -2425,6 +2425,33 @@ var GigaPdfDoc = class {
|
|
|
2425
2425
|
const format = buf[0] === 1 ? "truetype" : buf[0] === 2 ? "otf" : buf[0] === 3 ? "cff" : "type1";
|
|
2426
2426
|
return { format, bytes: buf.subarray(1) };
|
|
2427
2427
|
}
|
|
2428
|
+
/**
|
|
2429
|
+
* Extract an embedded font as a **browser-loadable** sfnt by its **physical
|
|
2430
|
+
* identity** (`fontId` — the value {@link textElements} and
|
|
2431
|
+
* {@link embeddedFontsV2} report). The name-ambiguity-proof sibling of
|
|
2432
|
+
* {@link extractWebFont}: a form generator routinely embeds dozens of
|
|
2433
|
+
* same-`/BaseFont` wrappers over a handful of physical programs, each with
|
|
2434
|
+
* its own *partial* `/ToUnicode` — a name lookup can land on a homonym whose
|
|
2435
|
+
* 2-entry map drops accents the program actually carries. Resolving by
|
|
2436
|
+
* `fontId` pins the exact program, and the served `cmap` is rebuilt as the
|
|
2437
|
+
* **union of every wrapper** referencing it (explicit `/ToUnicode` entries
|
|
2438
|
+
* first — `preferWrapper`, the run's own {@link TextElementInfo.baseFont},
|
|
2439
|
+
* winning on conflict — then inferred fills). The subset is always served
|
|
2440
|
+
* as-is, never rejected for an incomplete map. `null` only when no embedded
|
|
2441
|
+
* program carries `fontId`.
|
|
2442
|
+
*/
|
|
2443
|
+
extractWebFontById(fontId, preferWrapper) {
|
|
2444
|
+
const buf = this.g._withStr(
|
|
2445
|
+
fontId,
|
|
2446
|
+
(ip, il) => this.g._withOptStr(
|
|
2447
|
+
preferWrapper,
|
|
2448
|
+
(pp, pl) => this.g._buffer((o) => this.ex().gp_extract_web_font_by_id(this.h, ip, il, pp, pl, o))
|
|
2449
|
+
)
|
|
2450
|
+
);
|
|
2451
|
+
if (buf.length === 0) return null;
|
|
2452
|
+
const format = buf[0] === 1 ? "truetype" : buf[0] === 2 ? "otf" : buf[0] === 3 ? "cff" : "type1";
|
|
2453
|
+
return { format, bytes: buf.subarray(1) };
|
|
2454
|
+
}
|
|
2428
2455
|
/**
|
|
2429
2456
|
* The fonts **embedded** in the document — each `{ baseFont, format }`. Pair
|
|
2430
2457
|
* with {@link extractFont} to pull a font's bytes out and re-embed them via
|
|
@@ -2434,6 +2461,30 @@ var GigaPdfDoc = class {
|
|
|
2434
2461
|
embeddedFonts() {
|
|
2435
2462
|
return this.g._json((o) => this.ex().gp_embedded_fonts_json(this.h, o));
|
|
2436
2463
|
}
|
|
2464
|
+
/**
|
|
2465
|
+
* The embedded fonts **deduplicated by physical program** — one
|
|
2466
|
+
* {@link EmbeddedFontV2} per `/FontFile*` stream, carrying its `fontId`,
|
|
2467
|
+
* format, glyph count and every `/BaseFont` wrapped around it. The
|
|
2468
|
+
* per-program sibling of {@link embeddedFonts} (kept intact); its `fontId`s
|
|
2469
|
+
* feed {@link extractWebFontById} / {@link webFontCoverage}. Sorted by
|
|
2470
|
+
* `fontId` for a deterministic output.
|
|
2471
|
+
*/
|
|
2472
|
+
embeddedFontsV2() {
|
|
2473
|
+
return this.g._json((o) => this.ex().gp_embedded_fonts_v2_json(this.h, o));
|
|
2474
|
+
}
|
|
2475
|
+
/**
|
|
2476
|
+
* The Unicode code points mapped by the `cmap` {@link extractWebFontById}
|
|
2477
|
+
* serves for `fontId` — sorted, deduplicated. Lets a host check, before
|
|
2478
|
+
* painting, whether a run's characters are covered by the served face (and
|
|
2479
|
+
* pick a fallback for the gaps). Empty when no embedded program carries
|
|
2480
|
+
* `fontId`.
|
|
2481
|
+
*/
|
|
2482
|
+
webFontCoverage(fontId) {
|
|
2483
|
+
return this.g._withStr(
|
|
2484
|
+
fontId,
|
|
2485
|
+
(p, l) => this.g._json((o) => this.ex().gp_web_font_coverage(this.h, p, l, o))
|
|
2486
|
+
);
|
|
2487
|
+
}
|
|
2437
2488
|
// convert PDF → X
|
|
2438
2489
|
toText() {
|
|
2439
2490
|
return this.g._str((o) => this.ex().gp_to_text(this.h, o));
|
|
@@ -3598,6 +3649,20 @@ var GigaPdfDoc = class {
|
|
|
3598
3649
|
setCheckbox(name, checked) {
|
|
3599
3650
|
return this.g._withStr(name, (p, l) => this.ex().gp_set_checkbox(this.h, p, l, checked ? 1 : 0)) === 0;
|
|
3600
3651
|
}
|
|
3652
|
+
/**
|
|
3653
|
+
* Set a checkbox to a **named** appearance state — the on-state export of
|
|
3654
|
+
* one of its widgets. A multi-widget checkbox names one export per widget
|
|
3655
|
+
* (e.g. `Oui` / `non` on French CERFA forms); {@link setCheckbox} with
|
|
3656
|
+
* `true` only ever reaches the first export, this reaches any of them.
|
|
3657
|
+
* `"Off"` unchecks every widget. Returns `false` when the field or state
|
|
3658
|
+
* doesn't exist.
|
|
3659
|
+
*/
|
|
3660
|
+
setCheckboxState(name, state) {
|
|
3661
|
+
return this.g._withStr(
|
|
3662
|
+
name,
|
|
3663
|
+
(nP, nL) => this.g._withStr(state, (sP, sL) => this.ex().gp_set_checkbox_state(this.h, nP, nL, sP, sL))
|
|
3664
|
+
) === 0;
|
|
3665
|
+
}
|
|
3601
3666
|
setRadio(name, value) {
|
|
3602
3667
|
return this.g._withStr(
|
|
3603
3668
|
name,
|