pdf-skryba 0.10.2 → 1.0.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 +36 -3
- package/README.md +22 -20
- package/dist/first-party/reader.js +1178 -1108
- package/dist/first-party/reader.js.map +4 -4
- package/dist/first-party.js +7 -7
- package/dist/first-party.js.map +2 -2
- package/dist/index.js +1202 -1132
- package/dist/index.js.map +4 -4
- package/dist/index.min.js +4 -4
- package/dist/light.js +6 -6
- package/dist/light.js.map +3 -3
- package/dist/light.min.js +1 -1
- package/dist/types/extractor/codecs/ccitt-fax.d.ts +3 -3
- package/dist/types/extractor/document-cache.d.ts +1 -1
- package/dist/types/extractor/extraction-cost.d.ts +2 -2
- package/dist/types/extractor/font-weight.d.ts +2 -2
- package/dist/types/extractor/glyph-positions.d.ts +14 -14
- package/dist/types/extractor/glyph-runs.d.ts +4 -4
- package/dist/types/extractor/glyph-window.d.ts +2 -2
- package/dist/types/extractor/pdf-aside-figures.d.ts +1 -1
- package/dist/types/extractor/pdf-bands.d.ts +2 -2
- package/dist/types/extractor/pdf-ccitt-images.d.ts +1 -1
- package/dist/types/extractor/pdf-colour-ours.d.ts +4 -4
- package/dist/types/extractor/pdf-decrypt.d.ts +1 -1
- package/dist/types/extractor/pdf-document-info.d.ts +4 -4
- package/dist/types/extractor/pdf-document-scale.d.ts +1 -1
- package/dist/types/extractor/pdf-embedded-images.d.ts +1 -1
- package/dist/types/extractor/pdf-facts.d.ts +3 -3
- package/dist/types/extractor/pdf-flate-images.d.ts +1 -1
- package/dist/types/extractor/pdf-font-bridge.d.ts +3 -3
- package/dist/types/extractor/pdf-font-objects.d.ts +5 -5
- package/dist/types/extractor/pdf-fonts/font-text.d.ts +6 -6
- package/dist/types/extractor/pdf-fonts/predefined-cmaps.d.ts +6 -6
- package/dist/types/extractor/pdf-fonts/type1-encoding.d.ts +1 -1
- package/dist/types/extractor/pdf-fonts/widths.d.ts +2 -2
- package/dist/types/extractor/pdf-glyph-source.d.ts +13 -14
- package/dist/types/extractor/pdf-hidden-text.d.ts +3 -3
- package/dist/types/extractor/pdf-image-anchors.d.ts +1 -1
- package/dist/types/extractor/pdf-image-pixels.d.ts +13 -13
- package/dist/types/extractor/pdf-image-refusal.d.ts +2 -2
- package/dist/types/extractor/pdf-images.d.ts +4 -4
- package/dist/types/extractor/pdf-jpeg-images.d.ts +1 -1
- package/dist/types/extractor/pdf-layers.d.ts +1 -1
- package/dist/types/extractor/pdf-letter-spacing.d.ts +1 -1
- package/dist/types/extractor/pdf-line-breaks.d.ts +2 -2
- package/dist/types/extractor/pdf-links-ours.d.ts +2 -2
- package/dist/types/extractor/pdf-links.d.ts +2 -2
- package/dist/types/extractor/pdf-model.d.ts +8 -8
- package/dist/types/extractor/pdf-objects/bounds.d.ts +4 -4
- package/dist/types/extractor/pdf-objects/content.d.ts +4 -4
- package/dist/types/extractor/pdf-objects/document.d.ts +14 -14
- package/dist/types/extractor/pdf-objects/objects.d.ts +10 -10
- package/dist/types/extractor/pdf-objects/parse.d.ts +4 -4
- package/dist/types/extractor/pdf-objects/refusal.d.ts +2 -2
- package/dist/types/extractor/pdf-objects/streams.d.ts +4 -4
- package/dist/types/extractor/pdf-objects/xref.d.ts +3 -3
- package/dist/types/extractor/pdf-objstm-guard.d.ts +1 -1
- package/dist/types/extractor/pdf-objstm-source.d.ts +1 -1
- package/dist/types/extractor/pdf-open.d.ts +1 -1
- package/dist/types/extractor/pdf-ops-ours.d.ts +3 -3
- package/dist/types/extractor/pdf-ops.d.ts +9 -9
- package/dist/types/extractor/pdf-outline.d.ts +3 -3
- package/dist/types/extractor/pdf-page-content.d.ts +2 -2
- package/dist/types/extractor/pdf-page-figures.d.ts +1 -1
- package/dist/types/extractor/pdf-page-plan.d.ts +3 -3
- package/dist/types/extractor/pdf-page-stages.d.ts +2 -2
- package/dist/types/extractor/pdf-paragraphs.d.ts +1 -1
- package/dist/types/extractor/pdf-paths-ours.d.ts +4 -8
- package/dist/types/extractor/pdf-reference-ours.d.ts +2 -2
- package/dist/types/extractor/pdf-region-order.d.ts +2 -2
- package/dist/types/extractor/pdf-scanned.d.ts +2 -2
- package/dist/types/extractor/pdf-smask.d.ts +3 -3
- package/dist/types/extractor/pdf-source.d.ts +31 -32
- package/dist/types/extractor/pdf-stencil-images.d.ts +1 -1
- package/dist/types/extractor/pdf-structure.d.ts +1 -1
- package/dist/types/extractor/pdf-symbol-page.d.ts +2 -2
- package/dist/types/extractor/pdf-symbol-verdict.d.ts +3 -3
- package/dist/types/extractor/pdf-table-detector.d.ts +6 -6
- package/dist/types/extractor/pdf-table-render.d.ts +1 -1
- package/dist/types/extractor/text-writing-direction.d.ts +1 -1
- package/dist/types/layout/cell-text.d.ts +1 -1
- package/dist/types/layout/column-discriminant.d.ts +2 -2
- package/dist/types/layout/column-grid.d.ts +4 -4
- package/dist/types/layout/cut-word.d.ts +3 -3
- package/dist/types/layout/geometry.d.ts +3 -3
- package/dist/types/layout/grid-band.d.ts +3 -3
- package/dist/types/layout/gutter.d.ts +6 -6
- package/dist/types/layout/heading-sizes.d.ts +2 -2
- package/dist/types/layout/hidden-repaints.d.ts +1 -1
- package/dist/types/layout/hyphenation.d.ts +1 -1
- package/dist/types/layout/image-frontier.d.ts +1 -1
- package/dist/types/layout/induced-markers.d.ts +2 -2
- package/dist/types/layout/intervals.d.ts +3 -3
- package/dist/types/layout/list.d.ts +9 -9
- package/dist/types/layout/merged-cells.d.ts +1 -1
- package/dist/types/layout/mode.d.ts +2 -2
- package/dist/types/layout/superscript.d.ts +1 -1
- package/dist/types/layout/text-size.d.ts +1 -1
- package/dist/types/layout/vector-grid.d.ts +5 -5
- package/dist/types/lib/chunk.d.ts +1 -1
- package/dist/types/lib/extent.d.ts +2 -2
- package/dist/types/lib/link-schemes.d.ts +1 -1
- package/dist/types/lib/pdf-first-party.d.ts +4 -4
- package/dist/types/lib/pdf-light.d.ts +2 -2
- package/dist/types/lib/reader-options.d.ts +3 -3
- package/dist/types/lib/table-leading-bands.d.ts +2 -2
- package/dist/types/pipeline/cut-paragraph-repair.d.ts +1 -1
- package/dist/types/pipeline/glued-word-repair.d.ts +1 -1
- package/dist/types/pipeline/pdf-conservation-source.d.ts +8 -8
- package/package.json +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Matrix2D } from "../layout/geometry.js";
|
|
2
|
-
export interface
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export interface PdfOperator {
|
|
3
|
+
operator: string;
|
|
4
|
+
operands: unknown;
|
|
5
5
|
}
|
|
6
6
|
interface PathPoint {
|
|
7
7
|
x: number;
|
|
8
8
|
y: number;
|
|
9
9
|
}
|
|
10
|
-
export interface
|
|
11
|
-
|
|
10
|
+
export interface PdfPathOperand {
|
|
11
|
+
paintOperator: number;
|
|
12
12
|
paint?: string;
|
|
13
13
|
subpaths: PathPoint[][];
|
|
14
14
|
minMax?: number[];
|
|
@@ -29,15 +29,15 @@ export declare class HiddenLayerStack {
|
|
|
29
29
|
private hiddenCount;
|
|
30
30
|
enter(op: string, args: unknown, isLayerVisible: ((group: unknown) => boolean) | undefined): void;
|
|
31
31
|
leave(): void;
|
|
32
|
-
get
|
|
32
|
+
get isHidden(): boolean;
|
|
33
33
|
}
|
|
34
|
-
export declare function
|
|
34
|
+
export declare function decodeOperators(opList: {
|
|
35
35
|
fnArray: ArrayLike<number>;
|
|
36
36
|
argsArray: ArrayLike<unknown>;
|
|
37
|
-
}, OPS: Record<string, number>):
|
|
37
|
+
}, OPS: Record<string, number>): PdfOperator[];
|
|
38
38
|
export declare function decodePathSubpaths(packed: ArrayLike<number>): {
|
|
39
39
|
x: number;
|
|
40
40
|
y: number;
|
|
41
41
|
}[][];
|
|
42
|
-
export declare function
|
|
42
|
+
export declare function readPathOperand(args: unknown, OPS?: Record<string, number>): PdfPathOperand;
|
|
43
43
|
export {};
|
|
@@ -4,11 +4,11 @@ export interface PdfOutlineEntry {
|
|
|
4
4
|
depth: number;
|
|
5
5
|
}
|
|
6
6
|
export declare const OUTLINE_READ_MAX_ENTRIES = 2000;
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const OUTLINE_TITLE_MAX_CHARACTERS = 300;
|
|
8
8
|
export interface OutlineNode {
|
|
9
9
|
title?: unknown;
|
|
10
10
|
items?: OutlineNode[];
|
|
11
11
|
}
|
|
12
12
|
export declare function flattenOutline(tree: readonly OutlineNode[] | null | undefined): PdfOutlineEntry[] | undefined;
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function
|
|
13
|
+
export declare function readOutlineTree(doc: PdfObjectsDocument): OutlineNode[] | undefined;
|
|
14
|
+
export declare function readOutline(doc: PdfObjectsDocument): PdfOutlineEntry[] | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ContentOperator } from "./pdf-objects/content.js";
|
|
2
2
|
import type { PdfObjectsDocument, PdfPageEntry } from "./pdf-objects/document.js";
|
|
3
3
|
import type { PdfStream } from "./pdf-objects/objects.js";
|
|
4
|
-
export declare function parsedFormOf(doc: PdfObjectsDocument, form: PdfStream): readonly
|
|
4
|
+
export declare function parsedFormOf(doc: PdfObjectsDocument, form: PdfStream): readonly ContentOperator[];
|
|
5
5
|
export declare function pageContentOf(doc: PdfObjectsDocument, page: PdfPageEntry): Uint8Array;
|
|
@@ -14,7 +14,7 @@ export interface PageFigures {
|
|
|
14
14
|
places: readonly LostPlace[];
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
export declare const
|
|
17
|
+
export declare const findPageFigures: (store: ImageStore, cost: ExtractionCost, page: {
|
|
18
18
|
source: PdfSourcePage | undefined;
|
|
19
19
|
blockImages: readonly BlockImage[];
|
|
20
20
|
readEmbedded: EmbeddedImageReader | undefined;
|
|
@@ -15,7 +15,7 @@ export interface PageSlice {
|
|
|
15
15
|
readonly bands?: readonly ReadSegment<PdfTextRun>[];
|
|
16
16
|
readonly declared?: readonly PdfTextRun[][][];
|
|
17
17
|
readonly extents: readonly SegmentExtent[];
|
|
18
|
-
readonly
|
|
18
|
+
readonly isWholePage?: true;
|
|
19
19
|
}
|
|
20
20
|
export interface PicturePlace {
|
|
21
21
|
readonly top: number;
|
|
@@ -23,7 +23,7 @@ export interface PicturePlace {
|
|
|
23
23
|
readonly xMin: number;
|
|
24
24
|
readonly xMax: number;
|
|
25
25
|
readonly band: number | undefined;
|
|
26
|
-
readonly
|
|
26
|
+
readonly isReadable: boolean | undefined;
|
|
27
27
|
}
|
|
28
28
|
export interface DropCapPlace {
|
|
29
29
|
readonly letter: string;
|
|
@@ -50,5 +50,5 @@ export interface PagePlanReader {
|
|
|
50
50
|
declared: (items: readonly PdfTextRun[], rankOf: (item: PdfTextRun) => number | undefined) => PdfTextRun[][][];
|
|
51
51
|
declaredWholePage: (items: readonly PdfTextRun[], rankOf: (item: PdfTextRun) => number | undefined) => PdfTextRun[][][];
|
|
52
52
|
}
|
|
53
|
-
export declare const
|
|
53
|
+
export declare const createPagePlanReader: (cut: ColumnCut | undefined) => PagePlanReader;
|
|
54
54
|
export declare const pagePlanOf: (items: readonly PdfTextRun[], cut: ColumnCut | undefined) => PagePlan;
|
|
@@ -41,13 +41,13 @@ export interface PageContext {
|
|
|
41
41
|
}
|
|
42
42
|
export interface PageOutcome {
|
|
43
43
|
blocks: IRBlock[];
|
|
44
|
-
|
|
44
|
+
isScanned?: boolean;
|
|
45
45
|
deliberateRemovals?: string[];
|
|
46
46
|
tableBands?: {
|
|
47
47
|
top: number;
|
|
48
48
|
bottom: number;
|
|
49
49
|
}[];
|
|
50
|
-
|
|
50
|
+
hasFlattenedGrid?: boolean;
|
|
51
51
|
}
|
|
52
52
|
interface PageStage {
|
|
53
53
|
name: string;
|
|
@@ -13,4 +13,4 @@ export interface SegmentReading {
|
|
|
13
13
|
asidePicture?: ((line: Line) => number | undefined) | undefined;
|
|
14
14
|
}
|
|
15
15
|
export declare const asidePictureReader: (pictures: readonly ImageCandidate[]) => (line: Line) => number | undefined;
|
|
16
|
-
export declare const paragraphsFromSegment: (segment: readonly PositionedItem[][], reading: SegmentReading,
|
|
16
|
+
export declare const paragraphsFromSegment: (segment: readonly PositionedItem[][], reading: SegmentReading, shouldClassifyTextSizes?: boolean) => IRBlock[];
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import type { PdfValue } from "./pdf-objects/objects.js";
|
|
2
|
-
import { type
|
|
3
|
-
export declare const
|
|
2
|
+
import { type PdfPathOperand } from "./pdf-ops.js";
|
|
3
|
+
export declare const PATH_OPERATORS: Set<string>;
|
|
4
4
|
export declare class PathBuilder {
|
|
5
|
-
private
|
|
6
|
-
|
|
7
|
-
private start;
|
|
8
|
-
feed(op: string, operands: readonly PdfValue[]): PdfPathArg | undefined;
|
|
9
|
-
private rectangle;
|
|
10
|
-
private paint;
|
|
5
|
+
#private;
|
|
6
|
+
feed(operator: string, operands: readonly PdfValue[]): PdfPathOperand | undefined;
|
|
11
7
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { GlyphFragment } from "./glyph-positions.js";
|
|
2
|
-
import type {
|
|
3
|
-
export declare function
|
|
2
|
+
import type { PdfReferenceTextRun } from "./pdf-source.js";
|
|
3
|
+
export declare function buildReferenceTextRuns(glyphs: readonly GlyphFragment[], pageObjectId: string | undefined): PdfReferenceTextRun[];
|
|
@@ -2,5 +2,5 @@ import type { IRBlock } from "doc-ir";
|
|
|
2
2
|
import type { PageRegion } from "./pdf-model.js";
|
|
3
3
|
import type { PdfTextRun } from "./pdf-source.js";
|
|
4
4
|
export declare function interleaveRegions(items: readonly PdfTextRun[], regions: readonly PageRegion[], prose: (items: PdfTextRun[]) => IRBlock[]): IRBlock[];
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
5
|
+
export declare const computeReadingOrder: (regions: readonly PageRegion[]) => PageRegion[][];
|
|
6
|
+
export declare const groupVisualLines: (items: readonly PdfTextRun[]) => PdfTextRun[][];
|
|
@@ -12,12 +12,12 @@ export declare const ocrScannedPages: (bytes: Uint8Array, pageIndices: number[],
|
|
|
12
12
|
languages?: string[];
|
|
13
13
|
}) => Promise<Map<number, IRBlock[]>>;
|
|
14
14
|
export declare const extractPdfWithVision: (bytes: Uint8Array, vision: VisionPort, opts?: ExtractOptions) => Promise<{
|
|
15
|
-
|
|
15
|
+
document: IRDoc;
|
|
16
16
|
images?: RawImage[];
|
|
17
17
|
tableDetections?: PdfTableDetection[];
|
|
18
18
|
notices?: DocumentNotice[];
|
|
19
19
|
pageCount: number;
|
|
20
20
|
scannedPages?: number;
|
|
21
|
-
|
|
21
|
+
documentFacts: PdfDocumentFacts;
|
|
22
22
|
conservationSource: PdfConservationSource;
|
|
23
23
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PdfObjectsDocument } from "./pdf-objects/document.js";
|
|
2
2
|
import type { PdfStream, PdfValue } from "./pdf-objects/objects.js";
|
|
3
|
-
export declare function
|
|
4
|
-
|
|
3
|
+
export declare function isMaskSupported(doc: PdfObjectsDocument, mask: {
|
|
4
|
+
dictionary: ReadonlyMap<string, PdfValue>;
|
|
5
5
|
}): boolean;
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function resampleSoftMaskAlpha(doc: PdfObjectsDocument, mask: PdfStream, width: number, height: number): Uint8Array | undefined;
|
|
@@ -4,13 +4,13 @@ import type { FontWeight } from "./font-weight.js";
|
|
|
4
4
|
import { type PdfImageData } from "./pdf-images.js";
|
|
5
5
|
import { type GlyphFragment, type HidePolicy } from "./glyph-positions.js";
|
|
6
6
|
import { type GlyphMemo } from "./pdf-glyph-source.js";
|
|
7
|
-
import { type
|
|
7
|
+
import { type FontFacts } from "./pdf-symbol-verdict.js";
|
|
8
8
|
import { type PdfOutlineEntry } from "./pdf-outline.js";
|
|
9
9
|
import { type LayerConfig } from "./pdf-layers.js";
|
|
10
10
|
import type { PdfObjectsDocument } from "./pdf-objects/document.js";
|
|
11
|
-
import type {
|
|
11
|
+
import type { PdfOperator } from "./pdf-ops.js";
|
|
12
12
|
import type { Matrix2D } from "../layout/geometry.js";
|
|
13
|
-
export { OUTLINE_READ_MAX_ENTRIES,
|
|
13
|
+
export { OUTLINE_READ_MAX_ENTRIES, OUTLINE_TITLE_MAX_CHARACTERS, type PdfOutlineEntry } from "./pdf-outline.js";
|
|
14
14
|
export interface PdfTextRun {
|
|
15
15
|
text: string;
|
|
16
16
|
x: number;
|
|
@@ -21,13 +21,12 @@ export interface PdfTextRun {
|
|
|
21
21
|
matrix: Matrix2D;
|
|
22
22
|
fontId: string | undefined;
|
|
23
23
|
weight: FontWeight;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
isRotated: boolean;
|
|
25
|
+
isItalic?: boolean;
|
|
26
|
+
isLetterSpaced?: true;
|
|
27
27
|
hasEOL: boolean;
|
|
28
|
-
dir: string;
|
|
29
28
|
markedContentId: string | undefined;
|
|
30
|
-
|
|
29
|
+
isArtifact: boolean;
|
|
31
30
|
}
|
|
32
31
|
export interface PdfSourcePage {
|
|
33
32
|
width: number;
|
|
@@ -35,19 +34,19 @@ export interface PdfSourcePage {
|
|
|
35
34
|
bottom?: number;
|
|
36
35
|
runs: PdfTextRun[];
|
|
37
36
|
hasText: boolean;
|
|
38
|
-
|
|
37
|
+
operators: PdfOperator[];
|
|
39
38
|
isLayerVisible?: (group: unknown) => boolean;
|
|
40
39
|
readImage: (name: string) => PdfImageData | undefined;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
findImageReference: (name: string) => string | undefined;
|
|
41
|
+
findImageFailure: (name: string) => "slow" | "unreadable" | undefined;
|
|
42
|
+
findImageRefusal: (name: string) => PictureRefusal | undefined;
|
|
44
43
|
glyphs: GlyphFragment[];
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
glyphsUnavailableReason?: PdfTextUnreadReason;
|
|
45
|
+
hasUnreadFont?: true;
|
|
47
46
|
unreadObjects?: number;
|
|
48
47
|
declaredOrder?: readonly string[];
|
|
49
48
|
noteIds?: ReadonlySet<string>;
|
|
50
|
-
reference?:
|
|
49
|
+
reference?: PdfReferenceTextRun[];
|
|
51
50
|
links: PdfLinkAnnotation[];
|
|
52
51
|
}
|
|
53
52
|
export interface PdfLinkAnnotation {
|
|
@@ -58,18 +57,18 @@ export interface PdfDocumentInfo {
|
|
|
58
57
|
producer?: string;
|
|
59
58
|
creator?: string;
|
|
60
59
|
pdfVersion?: string;
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
isLinearized?: boolean;
|
|
61
|
+
hasForm?: boolean;
|
|
63
62
|
attachedFiles?: number;
|
|
64
63
|
signatures?: number;
|
|
65
64
|
}
|
|
66
|
-
export interface
|
|
65
|
+
export interface PdfReferenceTextRun {
|
|
67
66
|
text: string;
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
verticalCentre: number;
|
|
68
|
+
isArtifact?: true;
|
|
70
69
|
markedContentId?: string;
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
isRotated?: true;
|
|
71
|
+
isInNote?: true;
|
|
73
72
|
}
|
|
74
73
|
export interface PdfSource {
|
|
75
74
|
pages: PdfSourcePage[];
|
|
@@ -77,17 +76,17 @@ export interface PdfSource {
|
|
|
77
76
|
outline?: PdfOutlineEntry[];
|
|
78
77
|
info?: PdfDocumentInfo;
|
|
79
78
|
}
|
|
80
|
-
export declare const
|
|
79
|
+
export declare const placeNotesAfterText: (declaredOrder: readonly string[], runs: readonly PdfTextRun[], noteIds: ReadonlySet<string>) => readonly string[];
|
|
81
80
|
export declare const HOIST_MAX_COMPARISONS = 2000000;
|
|
82
81
|
export declare const hoistAgainstTree: (declaredOrder: readonly string[], runs: readonly PdfTextRun[]) => readonly string[];
|
|
83
82
|
interface ReadPdfSourceOptions {
|
|
84
83
|
onOpen?: ((pageCount: number) => void) | undefined;
|
|
85
84
|
firstPages?: number | undefined;
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
shouldKeepOperators?: ((pageIndex: number, runs: readonly PdfTextRun[], allRuns: readonly (readonly PdfTextRun[])[], allHasText: readonly boolean[]) => boolean) | undefined;
|
|
86
|
+
shouldKeepGlyphs?: ((pageIndex: number, runs: readonly PdfTextRun[], allRuns: readonly (readonly PdfTextRun[])[], allHasText: readonly boolean[]) => boolean) | undefined;
|
|
88
87
|
cost?: ExtractionCost | undefined;
|
|
89
88
|
}
|
|
90
|
-
export declare const
|
|
89
|
+
export declare const PDF_MAX_OPERATORS_PER_PAGE = 1000000;
|
|
91
90
|
interface ReadContext {
|
|
92
91
|
file: Uint8Array;
|
|
93
92
|
cost: ExtractionCost | undefined;
|
|
@@ -99,23 +98,23 @@ interface ReadContext {
|
|
|
99
98
|
}
|
|
100
99
|
interface PageText {
|
|
101
100
|
index: number;
|
|
102
|
-
ops:
|
|
103
|
-
fonts: ReadonlyMap<string,
|
|
101
|
+
ops: PdfOperator[];
|
|
102
|
+
fonts: ReadonlyMap<string, FontFacts>;
|
|
104
103
|
hide?: HidePolicy;
|
|
105
104
|
glyphs: GlyphFragment[];
|
|
106
105
|
glyphsUnavailable?: PdfTextUnreadReason;
|
|
107
106
|
fontUnread?: true;
|
|
108
107
|
unreadObjects?: number;
|
|
109
108
|
runs: PdfTextRun[];
|
|
110
|
-
reference:
|
|
109
|
+
reference: PdfReferenceTextRun[];
|
|
111
110
|
}
|
|
112
111
|
interface PageWants {
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
shouldKeepOperators: ReadPdfSourceOptions["shouldKeepOperators"];
|
|
113
|
+
shouldKeepGlyphs: ReadPdfSourceOptions["shouldKeepGlyphs"];
|
|
115
114
|
allRuns: readonly (readonly PdfTextRun[])[];
|
|
116
115
|
allHasText: readonly boolean[];
|
|
117
116
|
}
|
|
118
117
|
export declare function readPageText(ctx: ReadContext, pageIndex: number): PageText;
|
|
119
|
-
export declare function
|
|
118
|
+
export declare function classifyTextUnreadReason(error: unknown): PdfTextUnreadReason;
|
|
120
119
|
export declare function readPageSource(text: PageText, pageIndex: number, wants: PageWants, ctx: ReadContext): PdfSourcePage;
|
|
121
120
|
export declare function readPdfSource(bytes: Uint8Array, options?: ReadPdfSourceOptions): Promise<PdfSource>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PdfObjectsDocument } from "./pdf-objects/document.js";
|
|
2
2
|
import type { DecodedImageObject } from "./pdf-ccitt-images.js";
|
|
3
3
|
import { type PictureScope } from "./pdf-image-pixels.js";
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function decodeStencilImageObject(doc: PdfObjectsDocument, scope: PictureScope, name: string, kinds: {
|
|
5
5
|
rgba: number;
|
|
6
6
|
}, colour: string | undefined): DecodedImageObject | undefined;
|
|
@@ -3,4 +3,4 @@ export interface DeclaredStructure {
|
|
|
3
3
|
readonly declaredOrder: readonly string[];
|
|
4
4
|
readonly noteIds: ReadonlySet<string>;
|
|
5
5
|
}
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function readDeclaredStructure(doc: PdfObjectsDocument, page: PdfPageEntry): DeclaredStructure | undefined;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type FontFacts } from "./pdf-font-objects.js";
|
|
2
2
|
import type { PdfObjectsDocument, PdfPageEntry } from "./pdf-objects/document.js";
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function readPageFontFacts(doc: PdfObjectsDocument, page: PdfPageEntry): ReadonlyMap<string, FontFacts>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export type {
|
|
3
|
-
export declare function
|
|
1
|
+
import type { FontFacts } from "./pdf-font-objects.js";
|
|
2
|
+
export type { FontFacts };
|
|
3
|
+
export declare function isDeclaredSymbolFont(font: FontFacts | undefined): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ExtractionCost } from "./extraction-cost.js";
|
|
2
2
|
import { type LostPlace } from "./pdf-model.js";
|
|
3
|
-
import { GRAPHICS_STATE_MAX_DEPTH, type
|
|
3
|
+
import { GRAPHICS_STATE_MAX_DEPTH, type PdfOperator } from "./pdf-ops.js";
|
|
4
4
|
import { type PdfSource } from "./pdf-source.js";
|
|
5
5
|
import type { PdfTableDetection } from "../layout/geometry.js";
|
|
6
6
|
import { type CellRect, type MergeMap, type PdfTableOrigin, type LineSegment, type TableGrid } from "../layout/geometry.js";
|
|
@@ -13,7 +13,7 @@ interface ImageBox {
|
|
|
13
13
|
yMin: number;
|
|
14
14
|
yMax: number;
|
|
15
15
|
drawnWidth: number;
|
|
16
|
-
|
|
16
|
+
isArtifact: boolean;
|
|
17
17
|
}
|
|
18
18
|
export interface InlineImage {
|
|
19
19
|
xMin: number;
|
|
@@ -30,16 +30,16 @@ export interface BlockImage {
|
|
|
30
30
|
ref: string;
|
|
31
31
|
name: string;
|
|
32
32
|
drawnWidth: number;
|
|
33
|
-
|
|
33
|
+
isArtifact: boolean;
|
|
34
34
|
}
|
|
35
35
|
type FilledRect = PaintedBox;
|
|
36
36
|
interface PageWalk {
|
|
37
37
|
segments: LineSegment[];
|
|
38
38
|
filled: FilledRect[];
|
|
39
39
|
imageBoxes: ImageBox[];
|
|
40
|
-
|
|
40
|
+
hasOcrLayer: boolean;
|
|
41
41
|
}
|
|
42
|
-
export declare function walkPage(ops: readonly
|
|
42
|
+
export declare function walkPage(ops: readonly PdfOperator[], pageWidth: number, pageHeight: number, isLayerVisible?: (group: unknown) => boolean): PageWalk;
|
|
43
43
|
export interface PageTableGrid {
|
|
44
44
|
pageIndex: number;
|
|
45
45
|
origin: PdfTableOrigin;
|
|
@@ -73,6 +73,6 @@ export interface PdfPageSignals {
|
|
|
73
73
|
}>;
|
|
74
74
|
boxesByPage: Map<number, CellRect[]>;
|
|
75
75
|
}
|
|
76
|
-
export declare function detectPdfPageSignals(bytes: Uint8Array,
|
|
76
|
+
export declare function detectPdfPageSignals(bytes: Uint8Array, sharedSource?: PdfSource, cost?: ExtractionCost): Promise<PdfPageSignals>;
|
|
77
77
|
export declare function detectPdfTableGrids(bytes: Uint8Array): Promise<PageTableGrid[]>;
|
|
78
78
|
export declare function detectPdfTableOrigins(bytes: Uint8Array): Promise<PdfTableDetection[]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IRBlock } from "doc-ir";
|
|
2
2
|
import { type MergedCell, type MergeMap, type TableGrid } from "../layout/geometry.js";
|
|
3
3
|
import type { GlyphFragment } from "./glyph-positions.js";
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function collectRowCells<T>(byCase: readonly T[][][], rowIndex: number, merge: MergeMap | undefined): {
|
|
5
5
|
fragments: T[];
|
|
6
6
|
cell: MergedCell;
|
|
7
7
|
}[];
|
|
@@ -18,7 +18,7 @@ export interface CellLine {
|
|
|
18
18
|
raised?: ReadonlySet<Fragment>;
|
|
19
19
|
}
|
|
20
20
|
export declare const joinGlyphs: (drawn: readonly Fragment[]) => string;
|
|
21
|
-
export declare const
|
|
21
|
+
export declare const measureFirstWordWidth: (line: readonly {
|
|
22
22
|
text: string;
|
|
23
23
|
width: number;
|
|
24
24
|
}[]) => number;
|
|
@@ -12,12 +12,12 @@ export interface VerticalRhythm {
|
|
|
12
12
|
secondCount: number;
|
|
13
13
|
sampleSize: number;
|
|
14
14
|
}
|
|
15
|
-
export declare function
|
|
15
|
+
export declare function measureVerticalRhythm(fragmentsByLine: readonly Fragment[][]): VerticalRhythm | undefined;
|
|
16
16
|
export declare function hasRepeatedSecondRhythm(fragmentsByLine: readonly Fragment[][]): boolean;
|
|
17
17
|
export interface BandFragment {
|
|
18
18
|
text: string;
|
|
19
19
|
x: number;
|
|
20
20
|
width: number;
|
|
21
21
|
}
|
|
22
|
-
export declare function
|
|
22
|
+
export declare function hasProseInBands(fragments: readonly BandFragment[], cut: number): boolean;
|
|
23
23
|
export declare function looksLikeTextColumns(fragmentsByLine: readonly Fragment[][], cut: number): boolean;
|
|
@@ -3,9 +3,9 @@ interface GridColumn {
|
|
|
3
3
|
at: number;
|
|
4
4
|
right: number;
|
|
5
5
|
count: number;
|
|
6
|
-
|
|
6
|
+
characters: number;
|
|
7
7
|
}
|
|
8
|
-
type GridEvidence = "width" | "
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
8
|
+
type GridEvidence = "width" | "characters";
|
|
9
|
+
export declare function findColumnStarts(items: readonly GutterItem[]): GridColumn[];
|
|
10
|
+
export declare function findGridCuts(items: readonly GutterItem[], evidence: GridEvidence): number[];
|
|
11
11
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IRBlock } from "doc-ir";
|
|
2
2
|
import type { PageLanguage } from "doc-ir";
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const isCutAcrossLines: (previous: string, line: string) => boolean;
|
|
4
4
|
export declare const CUT_MARK = "\u00AD";
|
|
5
5
|
export declare const joinCutParagraphs: (blocks: readonly IRBlock[]) => IRBlock[];
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const resolveCutHyphens: (pages: readonly IRBlock[][],
|
|
6
|
+
export declare const selectHyphenationLanguage: (pages: readonly IRBlock[][], pageLanguage: PageLanguage | undefined) => PageLanguage | undefined;
|
|
7
|
+
export declare const resolveCutHyphens: (pages: readonly IRBlock[][], language?: PageLanguage) => IRBlock[][];
|
|
@@ -2,9 +2,9 @@ export type { PdfTableDetection, PdfTableOrigin } from "doc-ir";
|
|
|
2
2
|
export type { CellRect, ClassifiedLine, Fragment, LineSegment, MergedCell, MergeMap, Matrix2D, TableGrid, } from "doc-ir/internal";
|
|
3
3
|
export { clusterPositions } from "./position-clusters.js";
|
|
4
4
|
export { applyMatrix, classifyLineSegment, composeMatrix, IDENTITY_MATRIX, positionKey, subpathsToSegments, translateMatrix, } from "doc-ir/internal";
|
|
5
|
-
export { buildGridFromVectorLines, buildGridsFromVectorLines,
|
|
5
|
+
export { buildGridFromVectorLines, buildGridsFromVectorLines, removeImageFrames } from "./vector-grid.js";
|
|
6
6
|
export { findCellsByIntersection, isBoxesInVoidsRegion } from "./intersection-cells.js";
|
|
7
7
|
export { buildGridFromAlignedRows, detectAlignedColumns, hasWeakTabularitySignal, identifyAlignedTableLines, } from "./aligned-grid.js";
|
|
8
8
|
export { assignFragmentsToCells, groupFragmentsIntoRowBands, groupFragmentsIntoVisualLines } from "./fragment-cells.js";
|
|
9
|
-
export {
|
|
10
|
-
export { detectColumnGutter, hasRepeatedSecondRhythm, looksLikeTextColumns,
|
|
9
|
+
export { findDominantTextSize } from "./text-size.js";
|
|
10
|
+
export { detectColumnGutter, hasRepeatedSecondRhythm, looksLikeTextColumns, measureVerticalRhythm, } from "./column-discriminant.js";
|
|
@@ -2,15 +2,15 @@ export interface GridBand {
|
|
|
2
2
|
top: number;
|
|
3
3
|
bottom: number;
|
|
4
4
|
}
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const computeGridBand: (grid: {
|
|
6
6
|
readonly rowBoundaries: readonly number[];
|
|
7
7
|
}) => GridBand;
|
|
8
8
|
export declare const isInBand: (y: number, bands: readonly GridBand[]) => boolean;
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const computeLineMiddle: (line: {
|
|
10
10
|
readonly y: number;
|
|
11
11
|
readonly fontSize: number;
|
|
12
12
|
}) => number;
|
|
13
|
-
export declare const
|
|
13
|
+
export declare const isLineInBand: (line: {
|
|
14
14
|
readonly y: number;
|
|
15
15
|
readonly fontSize: number;
|
|
16
16
|
}, bands: readonly GridBand[]) => boolean;
|
|
@@ -9,12 +9,12 @@ export interface Gutter {
|
|
|
9
9
|
columnPt: number;
|
|
10
10
|
}
|
|
11
11
|
export declare function findGutters(items: readonly GutterItem[]): Gutter[];
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function
|
|
15
|
-
export declare function
|
|
16
|
-
export declare function
|
|
17
|
-
export declare function
|
|
12
|
+
export declare function findColumnCuts(items: readonly GutterItem[]): number[];
|
|
13
|
+
export declare function findColumnCut(items: readonly GutterItem[]): number | undefined;
|
|
14
|
+
export declare function findDocumentColumnCut(pages: readonly (readonly GutterItem[])[]): number | undefined;
|
|
15
|
+
export declare function findDocumentColumnCuts(pages: readonly (readonly GutterItem[])[]): number[];
|
|
16
|
+
export declare function findDocumentCuts(pages: readonly (readonly GutterItem[])[], cutsOfPage: (page: readonly GutterItem[]) => readonly number[]): number[];
|
|
17
|
+
export declare function rankDocumentCuts(pages: readonly (readonly GutterItem[])[], cutsOfPage: (page: readonly GutterItem[]) => readonly number[]): {
|
|
18
18
|
all: number[];
|
|
19
19
|
dominant: number | undefined;
|
|
20
20
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export declare const DEFAULT_HEADING_SIZE_RATIO = 1.2;
|
|
2
2
|
export declare const MAX_LEVEL = 6;
|
|
3
3
|
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function findBodySize(charactersBySize: ReadonlyMap<number, number>): number | undefined;
|
|
5
5
|
export interface SizeFacts {
|
|
6
6
|
pageCount: number;
|
|
7
7
|
lettersBySize: ReadonlyMap<number, number>;
|
|
8
8
|
pagesBySize: ReadonlyMap<number, ReadonlySet<number>>;
|
|
9
9
|
}
|
|
10
|
-
export declare function
|
|
10
|
+
export declare function classifySizes(charsBySize: ReadonlyMap<number, number>, ratio?: number, facts?: SizeFacts): {
|
|
11
11
|
body: ReadonlySet<number>;
|
|
12
12
|
bodySize: number | undefined;
|
|
13
13
|
levels: Map<number, HeadingLevel>;
|
|
@@ -7,4 +7,4 @@ export interface PaintedBox {
|
|
|
7
7
|
}
|
|
8
8
|
export declare const HIDDEN_REPAINT_GROUP_LIMIT = 512;
|
|
9
9
|
export declare const HIDDEN_REPAINT_PAGE_LIMIT = 4096;
|
|
10
|
-
export declare function
|
|
10
|
+
export declare function findHiddenRepaintFills(fills: readonly PaintedBox[], tolerancePt: number, maxInsetPt: number, minWidthRatio: number): Set<PaintedBox>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { PageLanguage } from "doc-ir";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const buildLegalCutTest: (language: PageLanguage) => ((left: string, right: string) => boolean);
|
|
@@ -2,8 +2,8 @@ export interface MarkerLine {
|
|
|
2
2
|
text: string;
|
|
3
3
|
left: number;
|
|
4
4
|
}
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const readLeadingMarkerToken: (text: string) => {
|
|
6
6
|
token: string;
|
|
7
7
|
length: number;
|
|
8
8
|
} | undefined;
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function induceMarkers(lines: readonly MarkerLine[]): string[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export interface Interval {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
low: number;
|
|
3
|
+
high: number;
|
|
4
4
|
}
|
|
5
5
|
export declare const mergeIntervals: (spans: readonly Interval[], tolerance: number) => Interval[];
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const measureUnionLength: (intervals: readonly (readonly [number, number])[]) => number;
|
|
7
7
|
export declare function lowerBound(length: number, predicate: (index: number) => boolean): number;
|