@qrcommunication/gigapdf-lib 0.27.0 → 0.29.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
@@ -271,6 +271,48 @@ interface Element extends Partial<Box> {
271
271
  kind: "text" | "image" | "shape";
272
272
  label: string;
273
273
  }
274
+ /**
275
+ * A text element from {@link GigaPdfDoc.textElements}: the decoded text plus
276
+ * everything a host editor needs to recreate the run. `index` is the text-run
277
+ * index accepted by {@link GigaPdfDoc.replaceText}; the bounding box is page
278
+ * user space (origin bottom-left).
279
+ */
280
+ interface TextElementInfo {
281
+ index: number;
282
+ text: string;
283
+ x: number;
284
+ y: number;
285
+ width: number;
286
+ height: number;
287
+ /** Resolved `/BaseFont` family (e.g. "Helvetica", "Times New Roman"). */
288
+ fontFamily: string;
289
+ bold: boolean;
290
+ italic: boolean;
291
+ /** Effective glyph size in points. */
292
+ fontSize: number;
293
+ /** RGB fill colour, `0..1` per channel. */
294
+ color: [number, number, number];
295
+ /** Baseline rotation in degrees (0 = upright). */
296
+ rotation: number;
297
+ }
298
+ /**
299
+ * An image element from {@link GigaPdfDoc.imageElements}: its placement box
300
+ * (page user space, origin bottom-left), the embeddable encoded bytes + format,
301
+ * and the source pixel dimensions. `data` is empty when `format` is `"unknown"`.
302
+ */
303
+ interface ImageElementInfo {
304
+ index: number;
305
+ x: number;
306
+ y: number;
307
+ width: number;
308
+ height: number;
309
+ /** `"jpeg"` | `"png"` | `"jp2"` | `"unknown"`. */
310
+ format: string;
311
+ pixelWidth: number;
312
+ pixelHeight: number;
313
+ /** Embeddable encoded image bytes (empty when `format === "unknown"`). */
314
+ data: Uint8Array;
315
+ }
274
316
  interface TextLine extends Box {
275
317
  text: string;
276
318
  }
@@ -432,6 +474,23 @@ declare class GigaPdfDoc {
432
474
  saveCompressed(): Uint8Array;
433
475
  textRuns(page: number): TextRunInfo[];
434
476
  elements(page: number): Element[];
477
+ /**
478
+ * Every text element on a page, enriched for an editor: the decoded text, its
479
+ * bounding box (user space, bottom-left), the resolved font family +
480
+ * bold/italic, the effective point size, the RGB fill colour and the baseline
481
+ * rotation. `index` is the text-run index for {@link replaceText}, so a host
482
+ * can extract, render and edit text from one model — the native replacement
483
+ * for a reader's per-run text layer (which `elements()` omits font + colour).
484
+ */
485
+ textElements(page: number): TextElementInfo[];
486
+ /**
487
+ * Every image element on a page: its placement box (user space, bottom-left),
488
+ * the embeddable encoded bytes (`data`) + `format` (`jpeg`/`png`/`jp2`/
489
+ * `unknown`), and the source pixel dimensions. DCTDecode/JPXDecode images pass
490
+ * through as jpeg/jp2; Flate/raw DeviceRGB|DeviceGray are re-encoded to PNG.
491
+ * The native replacement for a reader's image extraction (bytes + placement).
492
+ */
493
+ imageElements(page: number): ImageElementInfo[];
435
494
  structuredText(page: number): TextLine[];
436
495
  search(query: string, caseInsensitive?: boolean): SearchHit[];
437
496
  /** OCR a (scanned) page → words with PDF-space boxes. `scale` ≥ 2 for small text. */
@@ -731,4 +790,4 @@ declare class GigaPdfDoc {
731
790
  }): boolean;
732
791
  }
733
792
 
734
- 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 LayerInfo, type LinkInfo, type NamedDest, type OcrWord, type OutlineEntry, type PageInfo, type RadioOption, type SearchHit, type SignP12Options, type TextLine, type TextRunInfo, type XlsxSheet };
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 };
package/dist/index.d.ts CHANGED
@@ -271,6 +271,48 @@ interface Element extends Partial<Box> {
271
271
  kind: "text" | "image" | "shape";
272
272
  label: string;
273
273
  }
274
+ /**
275
+ * A text element from {@link GigaPdfDoc.textElements}: the decoded text plus
276
+ * everything a host editor needs to recreate the run. `index` is the text-run
277
+ * index accepted by {@link GigaPdfDoc.replaceText}; the bounding box is page
278
+ * user space (origin bottom-left).
279
+ */
280
+ interface TextElementInfo {
281
+ index: number;
282
+ text: string;
283
+ x: number;
284
+ y: number;
285
+ width: number;
286
+ height: number;
287
+ /** Resolved `/BaseFont` family (e.g. "Helvetica", "Times New Roman"). */
288
+ fontFamily: string;
289
+ bold: boolean;
290
+ italic: boolean;
291
+ /** Effective glyph size in points. */
292
+ fontSize: number;
293
+ /** RGB fill colour, `0..1` per channel. */
294
+ color: [number, number, number];
295
+ /** Baseline rotation in degrees (0 = upright). */
296
+ rotation: number;
297
+ }
298
+ /**
299
+ * An image element from {@link GigaPdfDoc.imageElements}: its placement box
300
+ * (page user space, origin bottom-left), the embeddable encoded bytes + format,
301
+ * and the source pixel dimensions. `data` is empty when `format` is `"unknown"`.
302
+ */
303
+ interface ImageElementInfo {
304
+ index: number;
305
+ x: number;
306
+ y: number;
307
+ width: number;
308
+ height: number;
309
+ /** `"jpeg"` | `"png"` | `"jp2"` | `"unknown"`. */
310
+ format: string;
311
+ pixelWidth: number;
312
+ pixelHeight: number;
313
+ /** Embeddable encoded image bytes (empty when `format === "unknown"`). */
314
+ data: Uint8Array;
315
+ }
274
316
  interface TextLine extends Box {
275
317
  text: string;
276
318
  }
@@ -432,6 +474,23 @@ declare class GigaPdfDoc {
432
474
  saveCompressed(): Uint8Array;
433
475
  textRuns(page: number): TextRunInfo[];
434
476
  elements(page: number): Element[];
477
+ /**
478
+ * Every text element on a page, enriched for an editor: the decoded text, its
479
+ * bounding box (user space, bottom-left), the resolved font family +
480
+ * bold/italic, the effective point size, the RGB fill colour and the baseline
481
+ * rotation. `index` is the text-run index for {@link replaceText}, so a host
482
+ * can extract, render and edit text from one model — the native replacement
483
+ * for a reader's per-run text layer (which `elements()` omits font + colour).
484
+ */
485
+ textElements(page: number): TextElementInfo[];
486
+ /**
487
+ * Every image element on a page: its placement box (user space, bottom-left),
488
+ * the embeddable encoded bytes (`data`) + `format` (`jpeg`/`png`/`jp2`/
489
+ * `unknown`), and the source pixel dimensions. DCTDecode/JPXDecode images pass
490
+ * through as jpeg/jp2; Flate/raw DeviceRGB|DeviceGray are re-encoded to PNG.
491
+ * The native replacement for a reader's image extraction (bytes + placement).
492
+ */
493
+ imageElements(page: number): ImageElementInfo[];
435
494
  structuredText(page: number): TextLine[];
436
495
  search(query: string, caseInsensitive?: boolean): SearchHit[];
437
496
  /** OCR a (scanned) page → words with PDF-space boxes. `scale` ≥ 2 for small text. */
@@ -731,4 +790,4 @@ declare class GigaPdfDoc {
731
790
  }): boolean;
732
791
  }
733
792
 
734
- 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 LayerInfo, type LinkInfo, type NamedDest, type OcrWord, type OutlineEntry, type PageInfo, type RadioOption, type SearchHit, type SignP12Options, type TextLine, type TextRunInfo, type XlsxSheet };
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 };
package/dist/index.js CHANGED
@@ -549,6 +549,33 @@ var GigaPdfDoc = class {
549
549
  elements(page) {
550
550
  return this.g._json((o) => this.ex().gp_elements_json(this.h, page, o));
551
551
  }
552
+ /**
553
+ * Every text element on a page, enriched for an editor: the decoded text, its
554
+ * bounding box (user space, bottom-left), the resolved font family +
555
+ * bold/italic, the effective point size, the RGB fill colour and the baseline
556
+ * rotation. `index` is the text-run index for {@link replaceText}, so a host
557
+ * can extract, render and edit text from one model — the native replacement
558
+ * for a reader's per-run text layer (which `elements()` omits font + colour).
559
+ */
560
+ textElements(page) {
561
+ return this.g._json((o) => this.ex().gp_text_elements_json(this.h, page, o));
562
+ }
563
+ /**
564
+ * Every image element on a page: its placement box (user space, bottom-left),
565
+ * the embeddable encoded bytes (`data`) + `format` (`jpeg`/`png`/`jp2`/
566
+ * `unknown`), and the source pixel dimensions. DCTDecode/JPXDecode images pass
567
+ * through as jpeg/jp2; Flate/raw DeviceRGB|DeviceGray are re-encoded to PNG.
568
+ * The native replacement for a reader's image extraction (bytes + placement).
569
+ */
570
+ imageElements(page) {
571
+ const raw = this.g._json(
572
+ (o) => this.ex().gp_image_elements_json(this.h, page, o)
573
+ );
574
+ return raw.map(({ dataBase64, ...rest }) => ({
575
+ ...rest,
576
+ data: this.g._fromBase64(dataBase64)
577
+ }));
578
+ }
552
579
  structuredText(page) {
553
580
  return this.g._json((o) => this.ex().gp_structured_text_json(this.h, page, o));
554
581
  }