-
-
Notifications
You must be signed in to change notification settings - Fork 84
/
index.d.ts
81 lines (69 loc) · 2.01 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
export type InitOptions = { password?: string; debug?: boolean };
export type Error = null | string;
export type DataEntry = {
page?: number;
width?: number;
height?: number;
text?: string;
file?: {
path?: string;
buffer?: string;
};
} | null;
export type ItemHandler = (err: Error, data: DataEntry) => void;
export declare class PdfReader {
constructor(opts?: InitOptions | null);
parseFileItems(pdfFilePath: string, itemHandler: ItemHandler): void;
parseBuffer(buffer: Buffer, itemHandler: ItemHandler): void;
}
export type Item = {
x: number;
y: number;
sw: number;
w: number;
A: string;
clr: number;
R: {
T: string;
S: number;
TS: any[];
}[];
text: string;
};
export type RuleAccumulator = (item: Item) => boolean | void;
export type RuleHandler<T = any> = (value: T) => void;
export interface TableResult {
matrix: string[][];
items: Item[];
}
export class TableParser {
private rows: { [key: string]: Item[] };
constructor();
processItem(item: Item, col: number): void;
processHeadingItem(item: Item, col: number): void;
getRows(): Item[][];
renderRows(): string;
/** row-> column-> items_collisionning_in_column-> item:Item */
getMatrix(): Item[][][];
getCleanMatrix(options?: { collisionSeparator: string }): string[][];
renderMatrix(): string;
}
export class Rule {
static on(regexp: RegExp): Rule;
static after(regexp: RegExp): Rule;
static makeItemProcessor(rules: Rule[]): (item: DataEntry) => void;
static addAccumulator(methodName: string, methodBuilder: Function): void;
constructor(regexp: RegExp);
// Accumulator methods
extractRegexpValues(): Rule;
parseNextItemValue(): Rule;
accumulateAfterHeading(): Rule;
accumulateFromSameX(): Rule;
parseColumns(...args: any[]): Rule;
parseTable(columnCount: number): Rule & {
then(handler: (result: TableResult) => void): Rule;
};
then<T>(handler: RuleHandler<T>): Rule;
private test(item: Item): RuleAccumulator | undefined;
private whenDone(callback: () => void): void;
}