@qrcommunication/gigapdf-lib 0.31.0 → 0.33.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/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
- /** A markup annotation (rect corners in PDF user space). */
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 {
@@ -455,6 +524,8 @@ interface PageInfo {
455
524
  width: number;
456
525
  height: number;
457
526
  rotation: number;
527
+ /** Raw `/MediaBox` `[x0, y0, x1, y1]` in user-space points (preserves origin). */
528
+ mediaBox: [number, number, number, number];
458
529
  }
459
530
  /** Visual styling for a newly-created form field. */
460
531
  interface FieldStyle {
@@ -505,6 +576,14 @@ declare class GigaPdfDoc {
505
576
  * The native replacement for a reader's image extraction (bytes + placement).
506
577
  */
507
578
  imageElements(page: number): ImageElementInfo[];
579
+ /**
580
+ * Every painted vector path on `page` (frames, rules, lines, filled shapes…)
581
+ * as geometry + style: segments and bounds in user space (origin bottom-left),
582
+ * fill/stroke RGB, line width, alpha and dash. Clip-only paths are omitted.
583
+ * The native replacement for walking a reader's operator list to rebuild the
584
+ * shape layer.
585
+ */
586
+ vectorPaths(page: number): VectorPathInfo[];
508
587
  structuredText(page: number): TextLine[];
509
588
  search(query: string, caseInsensitive?: boolean): SearchHit[];
510
589
  /** OCR a (scanned) page → words with PDF-space boxes. `scale` ≥ 2 for small text. */
@@ -804,4 +883,4 @@ declare class GigaPdfDoc {
804
883
  }): boolean;
805
884
  }
806
885
 
807
- 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 };
886
+ 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
- /** A markup annotation (rect corners in PDF user space). */
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 {
@@ -455,6 +524,8 @@ interface PageInfo {
455
524
  width: number;
456
525
  height: number;
457
526
  rotation: number;
527
+ /** Raw `/MediaBox` `[x0, y0, x1, y1]` in user-space points (preserves origin). */
528
+ mediaBox: [number, number, number, number];
458
529
  }
459
530
  /** Visual styling for a newly-created form field. */
460
531
  interface FieldStyle {
@@ -505,6 +576,14 @@ declare class GigaPdfDoc {
505
576
  * The native replacement for a reader's image extraction (bytes + placement).
506
577
  */
507
578
  imageElements(page: number): ImageElementInfo[];
579
+ /**
580
+ * Every painted vector path on `page` (frames, rules, lines, filled shapes…)
581
+ * as geometry + style: segments and bounds in user space (origin bottom-left),
582
+ * fill/stroke RGB, line width, alpha and dash. Clip-only paths are omitted.
583
+ * The native replacement for walking a reader's operator list to rebuild the
584
+ * shape layer.
585
+ */
586
+ vectorPaths(page: number): VectorPathInfo[];
508
587
  structuredText(page: number): TextLine[];
509
588
  search(query: string, caseInsensitive?: boolean): SearchHit[];
510
589
  /** OCR a (scanned) page → words with PDF-space boxes. `scale` ≥ 2 for small text. */
@@ -804,4 +883,4 @@ declare class GigaPdfDoc {
804
883
  }): boolean;
805
884
  }
806
885
 
807
- 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 };
886
+ 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 ptr = this.ex.gp_alloc(bytes.length);
52
- this.u8().set(bytes, ptr);
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
  }