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
|
@@ -7,7 +7,7 @@ export interface EmbeddedImage {
|
|
|
7
7
|
mimeType: "image/jpeg" | "image/png";
|
|
8
8
|
width: number;
|
|
9
9
|
height: number;
|
|
10
|
-
|
|
10
|
+
isViewOfFile?: true;
|
|
11
11
|
}
|
|
12
12
|
export type EmbeddedImageReader = (ref: string) => EmbeddedImage | undefined;
|
|
13
13
|
export declare function openEmbeddedImages(source: Uint8Array | PdfObjectsDocument): Promise<EmbeddedImageReader>;
|
|
@@ -10,9 +10,9 @@ export interface PdfDocumentFacts {
|
|
|
10
10
|
pdfVersion?: string;
|
|
11
11
|
tool?: PdfToolLabel;
|
|
12
12
|
toolVersion?: string;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
isTagged: boolean;
|
|
14
|
+
isLinearized?: true;
|
|
15
|
+
hasForm?: true;
|
|
16
16
|
}
|
|
17
17
|
interface ToolRule {
|
|
18
18
|
label: Exclude<PdfToolLabel, "other">;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PdfObjectsDocument } from "./pdf-objects/document.js";
|
|
2
2
|
import type { PictureScope } from "./pdf-image-pixels.js";
|
|
3
3
|
import type { DecodedImageObject } from "./pdf-ccitt-images.js";
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function decodeFlateImageObject(doc: PdfObjectsDocument, scope: PictureScope, name: string, kinds: {
|
|
5
5
|
rgb: number;
|
|
6
6
|
rgba: number;
|
|
7
7
|
}): DecodedImageObject | undefined;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ContentOperator } from "./pdf-objects/content.js";
|
|
2
2
|
export declare const SCOPE_SEPARATOR = "\0";
|
|
3
3
|
export type ResolvedForm = {
|
|
4
4
|
readonly scope: string;
|
|
5
5
|
} & ({
|
|
6
6
|
readonly data: Uint8Array;
|
|
7
7
|
} | {
|
|
8
|
-
readonly ops: readonly
|
|
8
|
+
readonly ops: readonly ContentOperator[];
|
|
9
9
|
});
|
|
10
10
|
export type FormResolver = (name: string, scope: string) => ResolvedForm | undefined;
|
|
11
|
-
export declare function
|
|
11
|
+
export declare function collectFontNames(content: Uint8Array, resolve: FormResolver): (string | undefined)[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PdfObjectsDocument } from "./pdf-objects/document.js";
|
|
2
|
-
import type {
|
|
3
|
-
export interface
|
|
2
|
+
import type { PdfDictionary } from "./pdf-objects/objects.js";
|
|
3
|
+
export interface FontFacts {
|
|
4
4
|
readonly weight: "bold" | "normal" | "unknown";
|
|
5
5
|
readonly italic?: boolean;
|
|
6
6
|
readonly name?: string;
|
|
@@ -9,6 +9,6 @@ export interface OurFontObject {
|
|
|
9
9
|
readonly isType3Font?: boolean;
|
|
10
10
|
readonly fontMatrix?: readonly number[] | undefined;
|
|
11
11
|
}
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function
|
|
12
|
+
export declare function classifyFontWeight(weightValue: number | undefined, name: string | undefined): "bold" | "normal" | "unknown";
|
|
13
|
+
export declare function classifyItalic(flags: number | undefined, italicAngle: number | undefined, name: string | undefined): boolean | undefined;
|
|
14
|
+
export declare function readFontFacts(doc: PdfObjectsDocument, font: PdfDictionary): FontFacts;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PdfDictionary, PdfStream, PdfValue } from "../pdf-objects/objects.js";
|
|
2
2
|
import { encodingNames } from "./names.js";
|
|
3
3
|
import { type TableBudget } from "./table-budget.js";
|
|
4
4
|
import { type ToUnicode } from "./to-unicode.js";
|
|
5
5
|
export interface FontReader {
|
|
6
6
|
resolve(value: PdfValue | undefined): PdfValue | undefined;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
resolveDictionary(value: PdfValue | undefined): PdfDictionary | undefined;
|
|
8
|
+
readStreamBytes(stream: PdfStream): Uint8Array;
|
|
9
9
|
}
|
|
10
|
-
export declare function
|
|
10
|
+
export declare function readEncodingChoice(reader: FontReader, font: PdfDictionary, builtIn?: string): Parameters<typeof encodingNames>[0];
|
|
11
11
|
export type FontTextMemo = Map<number, ToUnicode | undefined>;
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
12
|
+
export declare function readFontDeclaredText(reader: FontReader, font: PdfDictionary, memo?: FontTextMemo, budget?: TableBudget): (code: number) => string | undefined;
|
|
13
|
+
export declare function readFontText(reader: FontReader, font: PdfDictionary, memo?: FontTextMemo, budget?: TableBudget): (code: number) => string | undefined;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export type UnicodeCodeForm = "ucs2" | "utf16";
|
|
2
|
-
export declare function
|
|
3
|
-
export declare const
|
|
2
|
+
export declare function findUnicodeCodeForm(encoding: string): UnicodeCodeForm | undefined;
|
|
3
|
+
export declare const hasUnicodeScalarCodes: (encoding: string) => boolean;
|
|
4
4
|
export interface CidTable {
|
|
5
|
-
readonly
|
|
5
|
+
readonly mapCodeToCid: (code: number) => number | undefined;
|
|
6
6
|
readonly highest: number;
|
|
7
7
|
}
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
8
|
+
export declare function findCidTable(encoding: string): CidTable | undefined;
|
|
9
|
+
export declare function splitUnicodeCodes(bytes: Uint8Array, form: UnicodeCodeForm): number[];
|
|
10
|
+
export declare function decodeUnicodeCode(code: number): string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function readBuiltInType1Encoding(program: Uint8Array): readonly string[] | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PdfDictionary } from "../pdf-objects/objects.js";
|
|
2
2
|
import { type FontReader } from "./font-text.js";
|
|
3
3
|
import { type TableBudget } from "./table-budget.js";
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function readFontWidths(reader: FontReader, font: PdfDictionary, budget?: TableBudget): (code: number) => number | undefined;
|
|
@@ -1,44 +1,43 @@
|
|
|
1
1
|
import { type PdfObjectsDocument } from "./pdf-objects/document.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { PdfDictionary } from "./pdf-objects/objects.js";
|
|
3
3
|
import { type FontTextMemo } from "./pdf-fonts/font-text.js";
|
|
4
4
|
import type { TableBudget } from "./pdf-fonts/table-budget.js";
|
|
5
|
-
export interface
|
|
5
|
+
export interface DecodedGlyph {
|
|
6
6
|
readonly unicode: string | undefined;
|
|
7
7
|
readonly width: number | undefined;
|
|
8
8
|
readonly isSpace: boolean;
|
|
9
9
|
readonly read: "ours" | "default-font" | "not-ours";
|
|
10
10
|
}
|
|
11
11
|
export declare const MAX_FORM_DEPTH = 8;
|
|
12
|
-
export declare const MAX_STATE_DEPTH = 256;
|
|
13
12
|
export declare const MAX_SHOWN_GLYPHS_PER_PAGE = 1000000;
|
|
14
|
-
export interface
|
|
13
|
+
export interface FontCodeReader {
|
|
15
14
|
text: (code: number) => string | undefined;
|
|
16
15
|
width: (code: number) => number | undefined;
|
|
17
16
|
codesOf: (bytes: Uint8Array) => number[];
|
|
18
|
-
|
|
17
|
+
isSingleByte: boolean;
|
|
19
18
|
declared: (code: number) => string | undefined;
|
|
20
|
-
read:
|
|
19
|
+
read: DecodedGlyph["read"];
|
|
21
20
|
}
|
|
22
|
-
export declare const
|
|
21
|
+
export declare const DEFAULT_FONT_CODE_READER: FontCodeReader;
|
|
23
22
|
export interface GlyphMemo {
|
|
24
|
-
readonly fonts: Map<
|
|
23
|
+
readonly fonts: Map<PdfDictionary, FontCodeReader>;
|
|
25
24
|
readonly cmaps: FontTextMemo;
|
|
26
25
|
readonly tables: TableBudget;
|
|
27
26
|
}
|
|
28
|
-
export declare const
|
|
29
|
-
export declare function
|
|
27
|
+
export declare const createGlyphMemo: () => GlyphMemo;
|
|
28
|
+
export declare function buildFontCodeReader(doc: PdfObjectsDocument, declared: PdfDictionary | undefined, memo: GlyphMemo): FontCodeReader;
|
|
30
29
|
export interface GlyphBudget {
|
|
31
30
|
painted: number;
|
|
32
31
|
forms: number;
|
|
33
32
|
}
|
|
34
33
|
export declare function chargeFormCall(budget: Pick<GlyphBudget, "forms">): void;
|
|
35
|
-
export declare function
|
|
36
|
-
export type ShownGlyphs = readonly
|
|
37
|
-
export interface
|
|
34
|
+
export declare function appendStringGlyphs(bytes: Uint8Array, state: FontCodeReader, into: DecodedGlyph[], budget: GlyphBudget): void;
|
|
35
|
+
export type ShownGlyphs = readonly DecodedGlyph[];
|
|
36
|
+
export interface GlyphSource {
|
|
38
37
|
readonly pageCount: number;
|
|
39
38
|
readonly document: PdfObjectsDocument;
|
|
40
39
|
glyphsOfPage(index: number): readonly ShownGlyphs[];
|
|
41
40
|
readonly memo: GlyphMemo;
|
|
42
41
|
tableEntries(): number;
|
|
43
42
|
}
|
|
44
|
-
export declare function
|
|
43
|
+
export declare function openGlyphSource(bytes: Uint8Array): GlyphSource;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { GlyphFragment } from "./glyph-positions.js";
|
|
2
2
|
export declare const MAX_FILTERED_GLYPHS = 100000;
|
|
3
3
|
export declare function countShownGlyphs(ops: readonly {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
operator: string;
|
|
5
|
+
operands: unknown;
|
|
6
6
|
}[]): number;
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const shouldDropModeHidden: (glyphs: readonly GlyphFragment[]) => boolean;
|
|
@@ -5,7 +5,7 @@ import type { ImageAnchor, ImageCandidate, PageRegion } from "./pdf-model.js";
|
|
|
5
5
|
import type { PagePlanReader } from "./pdf-page-plan.js";
|
|
6
6
|
import type { PdfTextRun } from "./pdf-source.js";
|
|
7
7
|
export declare function placeImages(candidates: readonly ImageCandidate[]): ImageAnchor[];
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const createImageRegion: (a: ImageAnchor) => PageRegion;
|
|
9
9
|
export declare function interleaveImages(items: readonly PdfTextRun[], anchors: readonly ImageAnchor[], prose: (items: PdfTextRun[]) => IRBlock[], extra?: readonly PageRegion[]): IRBlock[];
|
|
10
10
|
export type BandLayout = "rows" | "flow" | "items" | "item-cells";
|
|
11
11
|
export declare const DEFAULT_BAND_LAYOUT: BandLayout;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import type { PdfObjectsDocument } from "./pdf-objects/document.js";
|
|
2
|
-
import { type
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
2
|
+
import { type PdfDictionary, type PdfValue } from "./pdf-objects/objects.js";
|
|
3
|
+
export declare const readName: (value: PdfValue | undefined) => string | undefined;
|
|
4
|
+
export declare const readNumber: (value: PdfValue | undefined) => number | undefined;
|
|
5
|
+
export declare const readEntry: (doc: PdfObjectsDocument, dict: PdfDictionary, key: string) => PdfValue | undefined;
|
|
6
6
|
export declare const MAX_EMBEDDED_IMAGE_PIXELS = 25000000;
|
|
7
7
|
export declare const MAX_JPEG_DECODE_MEMORY_MB = 256;
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
8
|
+
export declare function isImageSizeAllowed(width: number, height: number): boolean;
|
|
9
|
+
export declare function readJpegFrame(raw: Uint8Array): {
|
|
10
10
|
components: number;
|
|
11
11
|
width: number;
|
|
12
12
|
height: number;
|
|
13
13
|
} | undefined;
|
|
14
|
-
export declare function
|
|
15
|
-
export declare function
|
|
14
|
+
export declare function countColourSpaceComponents(doc: PdfObjectsDocument, space: PdfValue | undefined): number | undefined;
|
|
15
|
+
export declare function decodeJpegRgb(raw: Uint8Array, drawn?: {
|
|
16
16
|
width: number;
|
|
17
17
|
height: number;
|
|
18
18
|
}): {
|
|
@@ -22,7 +22,7 @@ export declare function rgbOf(raw: Uint8Array, drawn?: {
|
|
|
22
22
|
} | undefined;
|
|
23
23
|
export declare function decodeArrayOf(doc: PdfObjectsDocument, dict: ReadonlyMap<string, PdfValue>, components: number): (readonly [number, number])[] | undefined | null;
|
|
24
24
|
export declare function decodeSample(x: number, pair: readonly [number, number]): number;
|
|
25
|
-
export declare function
|
|
25
|
+
export declare function applyDecode(image: {
|
|
26
26
|
width: number;
|
|
27
27
|
height: number;
|
|
28
28
|
data: Uint8Array;
|
|
@@ -39,13 +39,13 @@ export declare function cmykToRgb(raw: Uint8Array, decodes: readonly (readonly [
|
|
|
39
39
|
height: number;
|
|
40
40
|
data: Uint8Array;
|
|
41
41
|
} | undefined;
|
|
42
|
-
export declare function
|
|
43
|
-
export declare function
|
|
42
|
+
export declare function readObjectReferenceKey(declared: PdfValue | undefined): string | undefined;
|
|
43
|
+
export declare function readIndexedColourSpace(doc: PdfObjectsDocument, space: PdfValue | undefined): {
|
|
44
44
|
base: number;
|
|
45
45
|
hival: number;
|
|
46
46
|
lookup: Uint8Array;
|
|
47
47
|
} | undefined;
|
|
48
|
-
export declare function unpackSamples(bytes: Uint8Array, width: number, height: number, components: number,
|
|
48
|
+
export declare function unpackSamples(bytes: Uint8Array, width: number, height: number, components: number, bitsPerComponent: number): Uint8Array | undefined;
|
|
49
49
|
export interface PictureScope {
|
|
50
|
-
readonly resources:
|
|
50
|
+
readonly resources: PdfDictionary | undefined;
|
|
51
51
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { PictureRefusal } from "doc-ir";
|
|
2
2
|
import { type PdfObjectsDocument } from "./pdf-objects/document.js";
|
|
3
|
-
import type {
|
|
4
|
-
export declare function
|
|
3
|
+
import type { PdfDictionary } from "./pdf-objects/objects.js";
|
|
4
|
+
export declare function findPictureRefusal(doc: PdfObjectsDocument, dict: PdfDictionary): PictureRefusal;
|
|
@@ -6,13 +6,13 @@ export interface PdfImageData {
|
|
|
6
6
|
format: PixelFormat;
|
|
7
7
|
data: ArrayLike<number>;
|
|
8
8
|
}
|
|
9
|
-
export interface
|
|
9
|
+
export interface PageObjectStore {
|
|
10
10
|
get: (objId: string) => unknown;
|
|
11
11
|
}
|
|
12
|
-
export interface
|
|
12
|
+
export interface ImageKinds {
|
|
13
13
|
GRAYSCALE_1BPP: number;
|
|
14
14
|
RGB_24BPP: number;
|
|
15
15
|
RGBA_32BPP: number;
|
|
16
16
|
}
|
|
17
|
-
export declare function readImageObject(
|
|
18
|
-
export declare function readImageRef(objs:
|
|
17
|
+
export declare function readImageObject(store: PageObjectStore, name: string, kinds: ImageKinds): PdfImageData | undefined;
|
|
18
|
+
export declare function readImageRef(objs: PageObjectStore, name: string): string | undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PdfObjectsDocument } from "./pdf-objects/document.js";
|
|
2
2
|
import type { PictureScope } from "./pdf-image-pixels.js";
|
|
3
3
|
import type { DecodedImageObject } from "./pdf-ccitt-images.js";
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function decodeJpegImageObject(doc: PdfObjectsDocument, scope: PictureScope, name: string, kinds: {
|
|
5
5
|
rgb: number;
|
|
6
6
|
rgba: number;
|
|
7
7
|
}): DecodedImageObject | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { GlyphFragment } from "./glyph-positions.js";
|
|
2
2
|
import type { PdfTextRun } from "./pdf-source.js";
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const computeRespacedText: (run: PdfTextRun, glyphs: readonly GlyphFragment[]) => string | undefined;
|
|
4
4
|
export declare const respaceLetterSpacedRuns: (runs: readonly PdfTextRun[], glyphs: readonly GlyphFragment[], onRespaced?: (copy: PdfTextRun, source: PdfTextRun) => void) => PdfTextRun[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { GlyphFragment } from "./glyph-positions.js";
|
|
2
2
|
import type { Line } from "./pdf-model.js";
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const createFirstWordWidthReader: (glyphs: readonly GlyphFragment[]) => (y: number, left?: number) => number;
|
|
4
4
|
export declare const isDeliberateBreak: (line: Line, next: Line, marginRight: number) => boolean;
|
|
5
5
|
export declare const isCentredPair: (line: Line, next: Line) => boolean;
|
|
6
6
|
export declare const continuesCentredLine: (line: Line, next: Line, containerWidth: number | undefined) => boolean;
|
|
@@ -10,7 +10,7 @@ export interface ContainerBox {
|
|
|
10
10
|
bottom: number;
|
|
11
11
|
top: number;
|
|
12
12
|
}
|
|
13
|
-
export declare const
|
|
13
|
+
export declare const createCentredContainerReader: (boxes: readonly ContainerBox[], cut: {
|
|
14
14
|
cut: number;
|
|
15
15
|
above?: number;
|
|
16
16
|
} | undefined, area: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { PdfObjectsDocument, PdfPageEntry } from "./pdf-objects/document.js";
|
|
2
2
|
import type { PdfLinkAnnotation } from "./pdf-source.js";
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
3
|
+
export declare function resolveAbsoluteTarget(raw: string): string | undefined;
|
|
4
|
+
export declare function readPageLinkAnnotations(doc: PdfObjectsDocument, page: PdfPageEntry): PdfLinkAnnotation[];
|
|
@@ -3,8 +3,8 @@ import type { PdfLinkSpan } from "./pdf-model.js";
|
|
|
3
3
|
import type { PdfLinkAnnotation, PdfTextRun } from "./pdf-source.js";
|
|
4
4
|
export declare const PDF_MAX_LINKS_PER_PAGE = 500;
|
|
5
5
|
export declare const fillBetween: (text: string, linkAt: (number | undefined)[], targetOf: (link: number) => string) => void;
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
6
|
+
export declare const findPageLinkSpans: <T extends PdfTextRun>(runs: readonly T[], glyphs: readonly GlyphFragment[], annotations: readonly PdfLinkAnnotation[]) => Map<T, PdfLinkSpan[]>;
|
|
7
|
+
export declare const buildPageLinkTie: <T extends PdfTextRun>(runs: readonly T[], glyphs: readonly GlyphFragment[], annotations: readonly PdfLinkAnnotation[]) => {
|
|
8
8
|
spansByRun: Map<T, PdfLinkSpan[]>;
|
|
9
9
|
hrefByGlyph: Map<GlyphFragment, string>;
|
|
10
10
|
};
|
|
@@ -5,7 +5,7 @@ import type { RawImage } from "doc-ir/internal";
|
|
|
5
5
|
import type { ExtractionCost } from "./extraction-cost.js";
|
|
6
6
|
import type { Fragment } from "../layout/geometry.js";
|
|
7
7
|
import type { PdfDocumentFacts } from "./pdf-facts.js";
|
|
8
|
-
import type {
|
|
8
|
+
import type { PdfReferenceTextRun, PdfTextRun } from "./pdf-source.js";
|
|
9
9
|
export declare const toFragment: (r: PdfTextRun) => Fragment;
|
|
10
10
|
export type PositionedItem = {
|
|
11
11
|
text: string;
|
|
@@ -14,8 +14,8 @@ export type PositionedItem = {
|
|
|
14
14
|
width: number;
|
|
15
15
|
fontSize: number;
|
|
16
16
|
links?: readonly PdfLinkSpan[];
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
isItalic?: boolean;
|
|
18
|
+
isRotated?: boolean;
|
|
19
19
|
};
|
|
20
20
|
export interface LostPlace {
|
|
21
21
|
readonly id: string;
|
|
@@ -44,11 +44,11 @@ export interface Line {
|
|
|
44
44
|
}
|
|
45
45
|
export interface TextRun {
|
|
46
46
|
text: string;
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
isBold: boolean;
|
|
48
|
+
isItalic?: boolean;
|
|
49
49
|
marker?: ImageRef;
|
|
50
50
|
href?: string;
|
|
51
|
-
|
|
51
|
+
isSuperscript?: boolean;
|
|
52
52
|
}
|
|
53
53
|
export interface ImageAnchor {
|
|
54
54
|
top: number;
|
|
@@ -90,7 +90,7 @@ export interface PdfExtractResult {
|
|
|
90
90
|
}>;
|
|
91
91
|
textUnreadByPage: ReadonlyMap<number, PdfTextUnreadReason>;
|
|
92
92
|
unreadObjectsByPage: ReadonlyMap<number, number>;
|
|
93
|
-
|
|
93
|
+
documentFacts: PdfDocumentFacts;
|
|
94
94
|
cost: ExtractionCost;
|
|
95
95
|
images?: RawImage[];
|
|
96
96
|
pagesOfImage?: ReadonlyMap<string, ReadonlySet<number>>;
|
|
@@ -101,7 +101,7 @@ export interface PdfExtractResult {
|
|
|
101
101
|
deliberateRemovals: string[];
|
|
102
102
|
deliberateRemovalsByPage: string[][];
|
|
103
103
|
reference: {
|
|
104
|
-
pages:
|
|
104
|
+
pages: PdfReferenceTextRun[][];
|
|
105
105
|
structureOrderByPage?: Map<number, string[]>;
|
|
106
106
|
singleReadingPages?: Set<number>;
|
|
107
107
|
tableBandsByPage?: Map<number, {
|
|
@@ -8,17 +8,17 @@ export declare const MAX_DECODED_STREAM_BYTES = 64000000;
|
|
|
8
8
|
export declare const MAX_OBJECT_STREAM_MEMBERS = 65536;
|
|
9
9
|
export declare const MAX_XREF_FIELD_BYTES = 8;
|
|
10
10
|
export declare const MAX_XREF_ENTRIES = 1048576;
|
|
11
|
-
export declare const
|
|
11
|
+
export declare const MAX_REFERENCE_HOPS = 8;
|
|
12
12
|
export declare const MAX_PAGE_TREE_DEPTH = 64;
|
|
13
13
|
export declare const MAX_PAGES = 50000;
|
|
14
14
|
export declare const MAX_OBJECT_STREAM_CACHE = 8;
|
|
15
15
|
export declare const MAX_CONTENT_OPERANDS = 64;
|
|
16
16
|
export declare const MAX_CONTENT_NODES = 2000000;
|
|
17
|
-
export declare const
|
|
17
|
+
export declare const MAX_CONTENT_OPERATORS = 1000000;
|
|
18
18
|
export declare const MAX_FORM_CALLS_PER_PAGE = 10000;
|
|
19
19
|
export declare const MAX_INLINE_IMAGE_ENTRIES = 64;
|
|
20
20
|
export declare const MAX_FILTER_CHAIN = 8;
|
|
21
21
|
export declare const MAX_VALUE_NODES = 1000000;
|
|
22
22
|
export declare const MAX_DOCUMENT_BYTES = 200000000;
|
|
23
|
-
export declare const
|
|
24
|
-
export declare const
|
|
23
|
+
export declare const HEAP_BYTES_PER_NODE = 48;
|
|
24
|
+
export declare const HEAP_BYTES_PER_OPERATOR = 110;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { PdfValue } from "./objects.js";
|
|
2
|
-
export interface
|
|
3
|
-
readonly
|
|
2
|
+
export interface ContentOperator {
|
|
3
|
+
readonly operator: string;
|
|
4
4
|
readonly operands: readonly PdfValue[];
|
|
5
5
|
}
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function readContentOperators(data: Uint8Array): readonly ContentOperator[];
|
|
7
7
|
export declare function tokenizeContent(data: Uint8Array): {
|
|
8
|
-
readonly ops: readonly
|
|
8
|
+
readonly ops: readonly ContentOperator[];
|
|
9
9
|
readonly nodes: number;
|
|
10
10
|
};
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PdfDictionary, PdfReference, PdfStream, PdfValue } from "./objects.js";
|
|
2
2
|
export interface PdfPageEntry {
|
|
3
|
-
readonly
|
|
4
|
-
readonly
|
|
5
|
-
readonly
|
|
6
|
-
readonly
|
|
7
|
-
readonly resources:
|
|
3
|
+
readonly reference: PdfReference;
|
|
4
|
+
readonly dictionary: PdfDictionary;
|
|
5
|
+
readonly visibleBox: readonly [number, number, number, number];
|
|
6
|
+
readonly rotation: number;
|
|
7
|
+
readonly resources: PdfDictionary | undefined;
|
|
8
8
|
}
|
|
9
9
|
export interface PdfObjectsDocument {
|
|
10
|
-
|
|
10
|
+
readTrailer(): PdfDictionary;
|
|
11
11
|
resolve(value: PdfValue | undefined): PdfValue | undefined;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
resolveDictionary(value: PdfValue | undefined): PdfDictionary | undefined;
|
|
13
|
+
readStreamBytes(stream: PdfStream): Uint8Array;
|
|
14
|
+
readRawStreamBytes(stream: PdfStream): Uint8Array;
|
|
15
|
+
readImageStream(stream: PdfStream): {
|
|
16
16
|
readonly imageFilter: string | undefined;
|
|
17
17
|
readonly data: Uint8Array;
|
|
18
18
|
};
|
|
19
|
-
|
|
19
|
+
readPages(): readonly PdfPageEntry[];
|
|
20
20
|
}
|
|
21
21
|
export declare function remember<K, V>(cache: Map<K, V>, key: K, value: V, max: number): V;
|
|
22
22
|
export declare function openPdfObjects(bytes: Uint8Array): PdfObjectsDocument;
|
|
23
|
-
export declare function
|
|
24
|
-
export declare function
|
|
23
|
+
export declare function readSingleFilter(doc: PdfObjectsDocument, dict: ReadonlyMap<string, PdfValue>): string | undefined;
|
|
24
|
+
export declare function readImageFilter(doc: PdfObjectsDocument, dict: ReadonlyMap<string, PdfValue>): string | undefined;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export type
|
|
2
|
-
export interface
|
|
1
|
+
export type PdfDictionary = ReadonlyMap<string, PdfValue>;
|
|
2
|
+
export interface PdfReference {
|
|
3
3
|
readonly kind: "ref";
|
|
4
|
-
readonly
|
|
5
|
-
readonly
|
|
4
|
+
readonly objectNumber: number;
|
|
5
|
+
readonly generationNumber: number;
|
|
6
6
|
}
|
|
7
|
-
export declare function
|
|
8
|
-
readonly
|
|
9
|
-
readonly
|
|
7
|
+
export declare function formatReferenceKey(ref: {
|
|
8
|
+
readonly objectNumber: number;
|
|
9
|
+
readonly generationNumber: number;
|
|
10
10
|
}): string;
|
|
11
11
|
export interface PdfStream {
|
|
12
12
|
readonly kind: "stream";
|
|
13
|
-
readonly
|
|
13
|
+
readonly dictionary: PdfDictionary;
|
|
14
14
|
readonly start: number;
|
|
15
15
|
readonly length: number;
|
|
16
16
|
}
|
|
@@ -33,5 +33,5 @@ export type PdfValue = {
|
|
|
33
33
|
readonly items: readonly PdfValue[];
|
|
34
34
|
} | {
|
|
35
35
|
readonly kind: "dict";
|
|
36
|
-
readonly entries:
|
|
37
|
-
} |
|
|
36
|
+
readonly entries: PdfDictionary;
|
|
37
|
+
} | PdfReference | PdfStream;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export type ResolveLength = (ref:
|
|
1
|
+
import type { PdfReference, PdfValue } from "./objects.js";
|
|
2
|
+
export type ResolveLength = (ref: PdfReference) => number | undefined;
|
|
3
3
|
export interface ParsedValue {
|
|
4
4
|
readonly value: PdfValue;
|
|
5
5
|
readonly end: number;
|
|
6
6
|
readonly nodes: number;
|
|
7
7
|
}
|
|
8
8
|
export interface ParsedObject {
|
|
9
|
-
readonly
|
|
10
|
-
readonly
|
|
9
|
+
readonly objectNumber: number;
|
|
10
|
+
readonly generationNumber: number;
|
|
11
11
|
readonly value: PdfValue;
|
|
12
12
|
readonly end: number;
|
|
13
13
|
readonly nodes: number;
|
|
@@ -6,7 +6,7 @@ export declare class PdfObjectsRefusal extends ReaderError {
|
|
|
6
6
|
readonly offset?: number | undefined;
|
|
7
7
|
constructor(reason: PdfObjectsRefusalReason, objectNumber?: number | undefined, offset?: number | undefined);
|
|
8
8
|
}
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const IS_BOUND_REFUSAL: Record<PdfObjectsRefusalReason, boolean>;
|
|
10
10
|
export declare function isSecurityRefusal(error: unknown): boolean;
|
|
11
11
|
export declare function rethrowSecurityRefusal(error: unknown): void;
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function readOptionalPart<T>(read: () => T): T | undefined;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PdfDictionary, PdfStream, PdfValue } from "./objects.js";
|
|
2
2
|
export type DecodeStream = (bytes: Uint8Array, stream: PdfStream) => Uint8Array;
|
|
3
3
|
export declare const IMAGE_FILTERS: ReadonlySet<string>;
|
|
4
4
|
export declare const decodeStream: DecodeStream;
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const decodeToImageFilter: (data: Uint8Array, dict:
|
|
5
|
+
export declare const findFilterChainRefusal: (dict: PdfDictionary) => "filters" | undefined;
|
|
6
|
+
export declare const decodeToImageFilter: (data: Uint8Array, dict: PdfDictionary) => {
|
|
7
7
|
readonly imageFilter: string | undefined;
|
|
8
8
|
readonly data: Uint8Array;
|
|
9
9
|
};
|
|
10
10
|
export interface ObjectStreamMembers {
|
|
11
11
|
readonly numbers: readonly number[];
|
|
12
|
-
|
|
12
|
+
readMemberValue(num: number): {
|
|
13
13
|
readonly value: PdfValue;
|
|
14
14
|
readonly nodes: number;
|
|
15
15
|
} | undefined;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PdfDictionary } from "./objects.js";
|
|
2
2
|
export type XrefEntry = {
|
|
3
3
|
readonly kind: "offset";
|
|
4
4
|
readonly offset: number;
|
|
5
|
-
readonly
|
|
5
|
+
readonly generationNumber: number;
|
|
6
6
|
} | {
|
|
7
7
|
readonly kind: "compressed";
|
|
8
8
|
readonly container: number;
|
|
@@ -10,7 +10,7 @@ export type XrefEntry = {
|
|
|
10
10
|
};
|
|
11
11
|
export interface Xref {
|
|
12
12
|
readonly entries: ReadonlyMap<number, XrefEntry>;
|
|
13
|
-
readonly trailer:
|
|
13
|
+
readonly trailer: PdfDictionary;
|
|
14
14
|
}
|
|
15
15
|
export declare const MAX_TABLE_TOKEN_BYTES = 32;
|
|
16
16
|
export type SpendBytes = (bytes: number) => void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ObjectStreamSource } from "./pdf-objstm-guard.js";
|
|
2
2
|
import type { PdfObjectsDocument } from "./pdf-objects/document.js";
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const createObjectStreamSource: (doc?: PdfObjectsDocument) => ObjectStreamSource;
|
|
@@ -6,5 +6,5 @@ export declare const openPdfSource: (bytes: Uint8Array, cost: ExtractionCost, pa
|
|
|
6
6
|
source: PdfSource;
|
|
7
7
|
items: PdfTextRun[][];
|
|
8
8
|
}>;
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const createGlyphReader: (source: PdfSource) => (pageIndex: number) => GlyphFragment[];
|
|
10
10
|
export declare const readPageSignals: (bytes: Uint8Array, source: PdfSource, cost: ExtractionCost) => Promise<PdfPageSignals>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PdfObjectsDocument, PdfPageEntry } from "./pdf-objects/document.js";
|
|
2
2
|
import { type GlyphMemo } from "./pdf-glyph-source.js";
|
|
3
|
-
import type
|
|
4
|
-
export declare function
|
|
5
|
-
export declare const
|
|
3
|
+
import { type PdfOperator } from "./pdf-ops.js";
|
|
4
|
+
export declare function readPageOperators(doc: PdfObjectsDocument, page: PdfPageEntry, memo?: GlyphMemo): PdfOperator[];
|
|
5
|
+
export declare const UNREADABLE_XOBJECT_OPERATOR = "unreadableXObject";
|