@chialab/pdfjs-lib 1.0.0-alpha.28 → 1.0.0-alpha.29

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.ts CHANGED
@@ -10,6 +10,12 @@ export * from './lib/StandardFontDataFactory';
10
10
  export * from './lib/AnnotationData';
11
11
  export * from './lib/CanvasGraphics';
12
12
  export * from './lib/SvgCanvasContext';
13
- export * from './lib/TextLayer';
13
+ export { type TextLayerRoot, type TextLayerNode, type TextLayerAnchor, type TextLayerFigure, type TextLayerElement, TEXT_LAYER_FONT_FAMILY, isTextNode, isAnchorNode, isFigureNode, isElementNode, createTextLayer, loadTextLayerFonts, loadDefaultFonts, } from './lib/TextLayer';
14
+ export declare const textLayerUtils: {
15
+ findNode: (root: import(".").TextLayerElement, callback: (node: import(".").TextLayerNode, parent: import(".").TextLayerElement) => boolean | null | undefined) => import(".").TextLayerNode | null;
16
+ findNodes: (node: import(".").TextLayerElement, callback: (node: import(".").TextLayerNode, parent: import(".").TextLayerElement) => boolean | null | undefined) => import(".").TextLayerNode[];
17
+ getNodeContents: (node: import(".").TextLayerNode) => string;
18
+ flattenNodes: (node: import(".").TextLayerNode | string) => import(".").TextLayerNode[];
19
+ };
14
20
  export * from './lib/TextLayer_v2';
15
21
  export * from './pdf.js/src/pdf.js';
@@ -9,9 +9,4 @@ declare const Path2DConstructor: {
9
9
  * @returns A promise that resolves to the canvas.
10
10
  */
11
11
  export declare function createCanvas(width: number, height: number): Promise<HTMLCanvasElement>;
12
- /**
13
- * Load the fonts.
14
- * @returns A promise that resolves when the fonts are loaded.
15
- */
16
- export declare function loadDefaultFonts(): Promise<void>;
17
12
  export { Path2DConstructor as Path2D };
@@ -1,7 +1,8 @@
1
- import type { PDFPageProxy } from '../pdf.js/src/display/api';
1
+ import type { PDFPageProxy, StructTreeContent } from '../pdf.js/src/display/api';
2
2
  import type { BaseCanvasFactory } from '../pdf.js/src/display/canvas_factory';
3
3
  import type { PageViewport } from '../pdf.js/src/display/display_utils';
4
4
  import { type AnnotationData } from './AnnotationData';
5
+ import type { StructTreeNodeWithAttrs } from './StructTreePage';
5
6
  import { type SvgRoot } from './Svg';
6
7
  export interface TextLayerNode {
7
8
  id?: string;
@@ -27,7 +28,6 @@ export interface TextLayerText extends TextLayerNode {
27
28
  left: number;
28
29
  scale?: number;
29
30
  }[];
30
- hyphen?: boolean;
31
31
  top: number;
32
32
  left: number;
33
33
  fontSize: number;
@@ -36,6 +36,7 @@ export interface TextLayerText extends TextLayerNode {
36
36
  fontFamily: string;
37
37
  fontFallback: string;
38
38
  dir: string;
39
+ hyphen?: boolean;
39
40
  scale?: number;
40
41
  angle?: number;
41
42
  }
@@ -59,7 +60,16 @@ export interface Glyph {
59
60
  }
60
61
  export declare const fontLoader: (bold?: boolean, italic?: boolean) => Promise<Uint8Array<ArrayBuffer>>;
61
62
  export declare function loadTextLayerFonts(document?: Document): Promise<void>;
63
+ /**
64
+ * @deprecated Use `loadTextLayerFonts` instead.
65
+ */
66
+ export declare const loadDefaultFonts: typeof loadTextLayerFonts;
62
67
  export declare const normalizeMarkedContentId: (idRef: unknown) => string | null;
68
+ export declare const getNodeContents: (node: TextLayerNode) => string;
69
+ export declare const findNode: (root: TextLayerElement, callback: (node: TextLayerNode, parent: TextLayerElement) => boolean | null | undefined) => TextLayerNode | null;
70
+ export declare const findNodes: (node: TextLayerElement, callback: (node: TextLayerNode, parent: TextLayerElement) => boolean | null | undefined) => TextLayerNode[];
71
+ export declare const flattenNodes: (node: TextLayerNode | string) => TextLayerNode[];
72
+ export declare const decorateStructTree: (node: StructTreeNodeWithAttrs | StructTreeContent, rootContainer: TextLayerRoot, graphics?: SvgRoot, annotations?: AnnotationData[], parents?: TextLayerElement[]) => void;
63
73
  export declare function createTextLayer(page: PDFPageProxy, { canvasFactory, viewport, outputScale, annotations, graphics, }: {
64
74
  canvasFactory: BaseCanvasFactory;
65
75
  viewport?: PageViewport;
@@ -1,6 +1,6 @@
1
1
  import type { PDFPageProxy } from '../pdf.js/src/display/api';
2
- import { type AnnotationData } from './AnnotationData';
3
- import { type SvgRoot } from './Svg';
2
+ import type { AnnotationData } from './AnnotationData';
3
+ import type { SvgRoot } from './Svg';
4
4
  import { type TextLayerRoot } from './TextLayer';
5
5
  export declare function createTextLayerV2(page: PDFPageProxy, { graphics, annotations: _annotations, }?: {
6
6
  graphics?: SvgRoot;