@qrcommunication/gigapdf-lib 0.30.0 → 0.32.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 +38 -0
- package/dist/index.cjs +13 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +93 -2
- package/dist/index.d.ts +93 -2
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/gigapdf.wasm +0 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -312,6 +312,48 @@ interface ImageElementInfo {
|
|
|
312
312
|
pixelHeight: number;
|
|
313
313
|
/** Embeddable encoded image bytes (empty when `format === "unknown"`). */
|
|
314
314
|
data: Uint8Array;
|
|
315
|
+
/** Rotation in degrees from the placement CTM (`0` = upright). */
|
|
316
|
+
rotation: number;
|
|
317
|
+
/** Non-stroking fill alpha (`/ExtGState` `/ca`), `0..=1` (`1` = opaque). */
|
|
318
|
+
opacity: number;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* One path segment from {@link GigaPdfDoc.vectorPaths} (page user space, origin
|
|
322
|
+
* bottom-left). `op` is `"M"` (move, 2 pts), `"L"` (line, 2 pts), `"C"` (cubic
|
|
323
|
+
* Bézier, 6 pts: cp1 cp2 end) or `"Z"` (close, 0 pts). `pts` is the flat
|
|
324
|
+
* coordinate list.
|
|
325
|
+
*/
|
|
326
|
+
interface PathSegment {
|
|
327
|
+
op: "M" | "L" | "C" | "Z";
|
|
328
|
+
pts: number[];
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* A painted vector path from {@link GigaPdfDoc.vectorPaths}: its geometry
|
|
332
|
+
* (segments, bounds) plus the graphics state — fill/stroke RGB (`0..=1`, `null`
|
|
333
|
+
* when the paint op doesn't fill/stroke), line width, alpha and dash. Clip-only
|
|
334
|
+
* paths are omitted. The native equivalent of a reader's shape/vector layer.
|
|
335
|
+
*/
|
|
336
|
+
interface VectorPathInfo {
|
|
337
|
+
index: number;
|
|
338
|
+
/** Whether `x0..y1` describe a real box (`false` for a degenerate path). */
|
|
339
|
+
hasBounds: boolean;
|
|
340
|
+
x0: number;
|
|
341
|
+
y0: number;
|
|
342
|
+
x1: number;
|
|
343
|
+
y1: number;
|
|
344
|
+
segments: PathSegment[];
|
|
345
|
+
/** Fill colour `[r,g,b]` in `0..=1`, or `null` when not filled. */
|
|
346
|
+
fill: [number, number, number] | null;
|
|
347
|
+
/** Stroke colour `[r,g,b]` in `0..=1`, or `null` when not stroked. */
|
|
348
|
+
stroke: [number, number, number] | null;
|
|
349
|
+
/** Line width (`w`) in user-space units. */
|
|
350
|
+
strokeWidth: number;
|
|
351
|
+
/** Non-stroking alpha (`/ca`), `0..=1`. */
|
|
352
|
+
fillAlpha: number;
|
|
353
|
+
/** Stroking alpha (`/CA`), `0..=1`. */
|
|
354
|
+
strokeAlpha: number;
|
|
355
|
+
/** Dash pattern (`d` array); empty for a solid line. */
|
|
356
|
+
dash: number[];
|
|
315
357
|
}
|
|
316
358
|
interface TextLine extends Box {
|
|
317
359
|
text: string;
|
|
@@ -341,7 +383,12 @@ interface SignP12Options {
|
|
|
341
383
|
/** `/ContactInfo` — how to reach the signer. */
|
|
342
384
|
contactInfo?: string;
|
|
343
385
|
}
|
|
344
|
-
/**
|
|
386
|
+
/**
|
|
387
|
+
* A markup annotation (rect corners in PDF user space, origin bottom-left).
|
|
388
|
+
* Carries the common metadata plus the type-specific geometry a host editor
|
|
389
|
+
* needs: text-markup `quadPoints`, freehand `inkList`, `stamp` name, and the
|
|
390
|
+
* link target (`linkUri` / `linkPage`).
|
|
391
|
+
*/
|
|
345
392
|
interface AnnotationInfo {
|
|
346
393
|
index: number;
|
|
347
394
|
subtype: string;
|
|
@@ -350,6 +397,28 @@ interface AnnotationInfo {
|
|
|
350
397
|
x1: number;
|
|
351
398
|
y1: number;
|
|
352
399
|
contents: string;
|
|
400
|
+
/** `/T` — author / title. Empty when absent. */
|
|
401
|
+
author: string;
|
|
402
|
+
/** `/Subj` — subject. Empty when absent. */
|
|
403
|
+
subject: string;
|
|
404
|
+
/** `/CreationDate` — raw PDF date (`D:YYYYMMDD…`). Empty when absent. */
|
|
405
|
+
created: string;
|
|
406
|
+
/** `/M` — raw PDF modification date. Empty when absent. */
|
|
407
|
+
modified: string;
|
|
408
|
+
/** `/Name` — stamp name (e.g. `"Approved"`). Empty when absent. */
|
|
409
|
+
name: string;
|
|
410
|
+
/** `/CA` non-stroking opacity, `0..=1` (`1` = opaque). */
|
|
411
|
+
opacity: number;
|
|
412
|
+
/** `/C` normalised to RGB `0..=1` (`[]` when no colour). */
|
|
413
|
+
color: number[];
|
|
414
|
+
/** `/QuadPoints` (8 values per quad) for text-markup annotations. */
|
|
415
|
+
quadPoints: number[];
|
|
416
|
+
/** `/InkList` — one inner array per freehand stroke (`x y x y …`). */
|
|
417
|
+
inkList: number[][];
|
|
418
|
+
/** Link external URI (`/A /URI`). Empty when internal/absent. */
|
|
419
|
+
linkUri: string;
|
|
420
|
+
/** Link internal destination page (1-based); `0` when external/absent. */
|
|
421
|
+
linkPage: number;
|
|
353
422
|
}
|
|
354
423
|
/** A hyperlink annotation; `kind` discriminates the target. */
|
|
355
424
|
interface LinkInfo {
|
|
@@ -390,6 +459,20 @@ interface OutlineEntry {
|
|
|
390
459
|
level: number;
|
|
391
460
|
title: string;
|
|
392
461
|
page?: number;
|
|
462
|
+
/** `/F` flag bit 2 — label drawn bold (present when read via {@link GigaPdfDoc.outline}). */
|
|
463
|
+
bold?: boolean;
|
|
464
|
+
/** `/F` flag bit 1 — label drawn italic. */
|
|
465
|
+
italic?: boolean;
|
|
466
|
+
/** `/C` RGB label colour, `0..1` per channel (black when absent in the PDF). */
|
|
467
|
+
color?: [number, number, number];
|
|
468
|
+
/** Destination fit type, lowercased (`"xyz"`/`"fit"`/`"fith"`/`"fitv"`/…). */
|
|
469
|
+
destKind?: string;
|
|
470
|
+
/** `/XYZ` top-left X (when `destKind === "xyz"`). */
|
|
471
|
+
x?: number;
|
|
472
|
+
/** `/XYZ` top-left Y. */
|
|
473
|
+
y?: number;
|
|
474
|
+
/** `/XYZ` magnification. */
|
|
475
|
+
zoom?: number;
|
|
393
476
|
}
|
|
394
477
|
/** A named destination from {@link GigaPdfDoc.namedDests}: a name → page anchor. */
|
|
395
478
|
interface NamedDest {
|
|
@@ -491,6 +574,14 @@ declare class GigaPdfDoc {
|
|
|
491
574
|
* The native replacement for a reader's image extraction (bytes + placement).
|
|
492
575
|
*/
|
|
493
576
|
imageElements(page: number): ImageElementInfo[];
|
|
577
|
+
/**
|
|
578
|
+
* Every painted vector path on `page` (frames, rules, lines, filled shapes…)
|
|
579
|
+
* as geometry + style: segments and bounds in user space (origin bottom-left),
|
|
580
|
+
* fill/stroke RGB, line width, alpha and dash. Clip-only paths are omitted.
|
|
581
|
+
* The native replacement for walking a reader's operator list to rebuild the
|
|
582
|
+
* shape layer.
|
|
583
|
+
*/
|
|
584
|
+
vectorPaths(page: number): VectorPathInfo[];
|
|
494
585
|
structuredText(page: number): TextLine[];
|
|
495
586
|
search(query: string, caseInsensitive?: boolean): SearchHit[];
|
|
496
587
|
/** OCR a (scanned) page → words with PDF-space boxes. `scale` ≥ 2 for small text. */
|
|
@@ -790,4 +881,4 @@ declare class GigaPdfDoc {
|
|
|
790
881
|
}): boolean;
|
|
791
882
|
}
|
|
792
883
|
|
|
793
|
-
export { type AnnotationInfo, type Attachment, type Box, type DecodedImage, type Element, type EmbeddedFont, type FieldInfo, type FieldKind, type FieldStyle, type FontInfo, GigaPdfDoc, GigaPdfEngine, type HtmlFont, type HtmlFontRequest, type HtmlMargins, type HtmlRenderOptions, type ImageElementInfo, type LayerInfo, type LinkInfo, type NamedDest, type OcrWord, type OutlineEntry, type PageInfo, type RadioOption, type SearchHit, type SignP12Options, type TextElementInfo, type TextLine, type TextRunInfo, type XlsxSheet };
|
|
884
|
+
export { type AnnotationInfo, type Attachment, type Box, type DecodedImage, type Element, type EmbeddedFont, type FieldInfo, type FieldKind, type FieldStyle, type FontInfo, GigaPdfDoc, GigaPdfEngine, type HtmlFont, type HtmlFontRequest, type HtmlMargins, type HtmlRenderOptions, type ImageElementInfo, type LayerInfo, type LinkInfo, type NamedDest, type OcrWord, type OutlineEntry, type PageInfo, type PathSegment, type RadioOption, type SearchHit, type SignP12Options, type TextElementInfo, type TextLine, type TextRunInfo, type VectorPathInfo, type XlsxSheet };
|
package/dist/index.d.ts
CHANGED
|
@@ -312,6 +312,48 @@ interface ImageElementInfo {
|
|
|
312
312
|
pixelHeight: number;
|
|
313
313
|
/** Embeddable encoded image bytes (empty when `format === "unknown"`). */
|
|
314
314
|
data: Uint8Array;
|
|
315
|
+
/** Rotation in degrees from the placement CTM (`0` = upright). */
|
|
316
|
+
rotation: number;
|
|
317
|
+
/** Non-stroking fill alpha (`/ExtGState` `/ca`), `0..=1` (`1` = opaque). */
|
|
318
|
+
opacity: number;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* One path segment from {@link GigaPdfDoc.vectorPaths} (page user space, origin
|
|
322
|
+
* bottom-left). `op` is `"M"` (move, 2 pts), `"L"` (line, 2 pts), `"C"` (cubic
|
|
323
|
+
* Bézier, 6 pts: cp1 cp2 end) or `"Z"` (close, 0 pts). `pts` is the flat
|
|
324
|
+
* coordinate list.
|
|
325
|
+
*/
|
|
326
|
+
interface PathSegment {
|
|
327
|
+
op: "M" | "L" | "C" | "Z";
|
|
328
|
+
pts: number[];
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* A painted vector path from {@link GigaPdfDoc.vectorPaths}: its geometry
|
|
332
|
+
* (segments, bounds) plus the graphics state — fill/stroke RGB (`0..=1`, `null`
|
|
333
|
+
* when the paint op doesn't fill/stroke), line width, alpha and dash. Clip-only
|
|
334
|
+
* paths are omitted. The native equivalent of a reader's shape/vector layer.
|
|
335
|
+
*/
|
|
336
|
+
interface VectorPathInfo {
|
|
337
|
+
index: number;
|
|
338
|
+
/** Whether `x0..y1` describe a real box (`false` for a degenerate path). */
|
|
339
|
+
hasBounds: boolean;
|
|
340
|
+
x0: number;
|
|
341
|
+
y0: number;
|
|
342
|
+
x1: number;
|
|
343
|
+
y1: number;
|
|
344
|
+
segments: PathSegment[];
|
|
345
|
+
/** Fill colour `[r,g,b]` in `0..=1`, or `null` when not filled. */
|
|
346
|
+
fill: [number, number, number] | null;
|
|
347
|
+
/** Stroke colour `[r,g,b]` in `0..=1`, or `null` when not stroked. */
|
|
348
|
+
stroke: [number, number, number] | null;
|
|
349
|
+
/** Line width (`w`) in user-space units. */
|
|
350
|
+
strokeWidth: number;
|
|
351
|
+
/** Non-stroking alpha (`/ca`), `0..=1`. */
|
|
352
|
+
fillAlpha: number;
|
|
353
|
+
/** Stroking alpha (`/CA`), `0..=1`. */
|
|
354
|
+
strokeAlpha: number;
|
|
355
|
+
/** Dash pattern (`d` array); empty for a solid line. */
|
|
356
|
+
dash: number[];
|
|
315
357
|
}
|
|
316
358
|
interface TextLine extends Box {
|
|
317
359
|
text: string;
|
|
@@ -341,7 +383,12 @@ interface SignP12Options {
|
|
|
341
383
|
/** `/ContactInfo` — how to reach the signer. */
|
|
342
384
|
contactInfo?: string;
|
|
343
385
|
}
|
|
344
|
-
/**
|
|
386
|
+
/**
|
|
387
|
+
* A markup annotation (rect corners in PDF user space, origin bottom-left).
|
|
388
|
+
* Carries the common metadata plus the type-specific geometry a host editor
|
|
389
|
+
* needs: text-markup `quadPoints`, freehand `inkList`, `stamp` name, and the
|
|
390
|
+
* link target (`linkUri` / `linkPage`).
|
|
391
|
+
*/
|
|
345
392
|
interface AnnotationInfo {
|
|
346
393
|
index: number;
|
|
347
394
|
subtype: string;
|
|
@@ -350,6 +397,28 @@ interface AnnotationInfo {
|
|
|
350
397
|
x1: number;
|
|
351
398
|
y1: number;
|
|
352
399
|
contents: string;
|
|
400
|
+
/** `/T` — author / title. Empty when absent. */
|
|
401
|
+
author: string;
|
|
402
|
+
/** `/Subj` — subject. Empty when absent. */
|
|
403
|
+
subject: string;
|
|
404
|
+
/** `/CreationDate` — raw PDF date (`D:YYYYMMDD…`). Empty when absent. */
|
|
405
|
+
created: string;
|
|
406
|
+
/** `/M` — raw PDF modification date. Empty when absent. */
|
|
407
|
+
modified: string;
|
|
408
|
+
/** `/Name` — stamp name (e.g. `"Approved"`). Empty when absent. */
|
|
409
|
+
name: string;
|
|
410
|
+
/** `/CA` non-stroking opacity, `0..=1` (`1` = opaque). */
|
|
411
|
+
opacity: number;
|
|
412
|
+
/** `/C` normalised to RGB `0..=1` (`[]` when no colour). */
|
|
413
|
+
color: number[];
|
|
414
|
+
/** `/QuadPoints` (8 values per quad) for text-markup annotations. */
|
|
415
|
+
quadPoints: number[];
|
|
416
|
+
/** `/InkList` — one inner array per freehand stroke (`x y x y …`). */
|
|
417
|
+
inkList: number[][];
|
|
418
|
+
/** Link external URI (`/A /URI`). Empty when internal/absent. */
|
|
419
|
+
linkUri: string;
|
|
420
|
+
/** Link internal destination page (1-based); `0` when external/absent. */
|
|
421
|
+
linkPage: number;
|
|
353
422
|
}
|
|
354
423
|
/** A hyperlink annotation; `kind` discriminates the target. */
|
|
355
424
|
interface LinkInfo {
|
|
@@ -390,6 +459,20 @@ interface OutlineEntry {
|
|
|
390
459
|
level: number;
|
|
391
460
|
title: string;
|
|
392
461
|
page?: number;
|
|
462
|
+
/** `/F` flag bit 2 — label drawn bold (present when read via {@link GigaPdfDoc.outline}). */
|
|
463
|
+
bold?: boolean;
|
|
464
|
+
/** `/F` flag bit 1 — label drawn italic. */
|
|
465
|
+
italic?: boolean;
|
|
466
|
+
/** `/C` RGB label colour, `0..1` per channel (black when absent in the PDF). */
|
|
467
|
+
color?: [number, number, number];
|
|
468
|
+
/** Destination fit type, lowercased (`"xyz"`/`"fit"`/`"fith"`/`"fitv"`/…). */
|
|
469
|
+
destKind?: string;
|
|
470
|
+
/** `/XYZ` top-left X (when `destKind === "xyz"`). */
|
|
471
|
+
x?: number;
|
|
472
|
+
/** `/XYZ` top-left Y. */
|
|
473
|
+
y?: number;
|
|
474
|
+
/** `/XYZ` magnification. */
|
|
475
|
+
zoom?: number;
|
|
393
476
|
}
|
|
394
477
|
/** A named destination from {@link GigaPdfDoc.namedDests}: a name → page anchor. */
|
|
395
478
|
interface NamedDest {
|
|
@@ -491,6 +574,14 @@ declare class GigaPdfDoc {
|
|
|
491
574
|
* The native replacement for a reader's image extraction (bytes + placement).
|
|
492
575
|
*/
|
|
493
576
|
imageElements(page: number): ImageElementInfo[];
|
|
577
|
+
/**
|
|
578
|
+
* Every painted vector path on `page` (frames, rules, lines, filled shapes…)
|
|
579
|
+
* as geometry + style: segments and bounds in user space (origin bottom-left),
|
|
580
|
+
* fill/stroke RGB, line width, alpha and dash. Clip-only paths are omitted.
|
|
581
|
+
* The native replacement for walking a reader's operator list to rebuild the
|
|
582
|
+
* shape layer.
|
|
583
|
+
*/
|
|
584
|
+
vectorPaths(page: number): VectorPathInfo[];
|
|
494
585
|
structuredText(page: number): TextLine[];
|
|
495
586
|
search(query: string, caseInsensitive?: boolean): SearchHit[];
|
|
496
587
|
/** OCR a (scanned) page → words with PDF-space boxes. `scale` ≥ 2 for small text. */
|
|
@@ -790,4 +881,4 @@ declare class GigaPdfDoc {
|
|
|
790
881
|
}): boolean;
|
|
791
882
|
}
|
|
792
883
|
|
|
793
|
-
export { type AnnotationInfo, type Attachment, type Box, type DecodedImage, type Element, type EmbeddedFont, type FieldInfo, type FieldKind, type FieldStyle, type FontInfo, GigaPdfDoc, GigaPdfEngine, type HtmlFont, type HtmlFontRequest, type HtmlMargins, type HtmlRenderOptions, type ImageElementInfo, type LayerInfo, type LinkInfo, type NamedDest, type OcrWord, type OutlineEntry, type PageInfo, type RadioOption, type SearchHit, type SignP12Options, type TextElementInfo, type TextLine, type TextRunInfo, type XlsxSheet };
|
|
884
|
+
export { type AnnotationInfo, type Attachment, type Box, type DecodedImage, type Element, type EmbeddedFont, type FieldInfo, type FieldKind, type FieldStyle, type FontInfo, GigaPdfDoc, GigaPdfEngine, type HtmlFont, type HtmlFontRequest, type HtmlMargins, type HtmlRenderOptions, type ImageElementInfo, type LayerInfo, type LinkInfo, type NamedDest, type OcrWord, type OutlineEntry, type PageInfo, type PathSegment, type RadioOption, type SearchHit, type SignP12Options, type TextElementInfo, type TextLine, type TextRunInfo, type VectorPathInfo, type XlsxSheet };
|
package/dist/index.js
CHANGED
|
@@ -48,8 +48,9 @@ var GigaPdfEngine = class _GigaPdfEngine {
|
|
|
48
48
|
}
|
|
49
49
|
/** Copy host bytes into wasm memory; returns the pointer (caller frees). */
|
|
50
50
|
_toWasm(bytes) {
|
|
51
|
-
const
|
|
52
|
-
this.
|
|
51
|
+
const src = bytes.buffer === this.ex.memory.buffer ? new Uint8Array(bytes) : bytes;
|
|
52
|
+
const ptr = this.ex.gp_alloc(src.length);
|
|
53
|
+
this.u8().set(src, ptr);
|
|
53
54
|
return ptr;
|
|
54
55
|
}
|
|
55
56
|
_free(ptr, len) {
|
|
@@ -576,6 +577,16 @@ var GigaPdfDoc = class {
|
|
|
576
577
|
data: this.g._fromBase64(dataBase64)
|
|
577
578
|
}));
|
|
578
579
|
}
|
|
580
|
+
/**
|
|
581
|
+
* Every painted vector path on `page` (frames, rules, lines, filled shapes…)
|
|
582
|
+
* as geometry + style: segments and bounds in user space (origin bottom-left),
|
|
583
|
+
* fill/stroke RGB, line width, alpha and dash. Clip-only paths are omitted.
|
|
584
|
+
* The native replacement for walking a reader's operator list to rebuild the
|
|
585
|
+
* shape layer.
|
|
586
|
+
*/
|
|
587
|
+
vectorPaths(page) {
|
|
588
|
+
return this.g._json((o) => this.ex().gp_vector_paths_json(this.h, page, o));
|
|
589
|
+
}
|
|
579
590
|
structuredText(page) {
|
|
580
591
|
return this.g._json((o) => this.ex().gp_structured_text_json(this.h, page, o));
|
|
581
592
|
}
|