forked from modesty/pdf2json
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pdfparser.d.ts
130 lines (115 loc) · 2.32 KB
/
pdfparser.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import { EventEmitter } from "events";
declare class Pdfparser extends EventEmitter {
constructor(context?: any, needRawText?: number, password?: string);
parseBuffer(buffer: Buffer, verbosity?: number): void;
loadPDF(pdfFilePath: string, verbosity?: number): Promise<void>
createParserStream(): ParserStream
on<K extends keyof EventMap>(eventName: K, listener: EventMap[K]): this
}
export type EventMap = {
"pdfParser_dataError": (errMsg: string) => void;
"pdfParser_dataReady": (pdfData: Output) => void;
"readable": (meta: Output["Meta"]) => void;
"data": (data: Output["Pages"][number] | null) => void;
}
declare class ParserStream {
//TODO
}
export interface Output {
Transcoder: string,
Meta: Record<string, any>
Pages: Page[]
}
export declare interface Page {
Width: number,
Height: number,
HLines: Line[],
VLines: Line[],
Fills: Fill[],
Texts: Text[],
Fields: Field[],
Boxsets: Boxset[]
}
export declare interface Fill {
x: number,
y: number,
w: number,
h: number,
oc?: string,
clr?: number
}
export declare interface Line {
x: number,
y: number,
w: number,
oc?: string,
clr?: number
}
export declare interface Text {
x: number,
y: number,
w: number,
sw: number,
A: 'left' | 'center' | 'right',
R: TextRun[]
oc?: string;
clr?: number;
}
export declare interface TextRun {
T: string,
S: number,
TS: [number, number, 0 | 1, 0 | 1]
RA?: number
}
export declare interface Boxset {
boxes: Box[],
id: {
Id: string,
EN?: number
}
}
export declare interface Field {
id: {
Id: string,
EN?: number
},
style: number,
TI: number,
AM: number,
TU: string,
x: number,
y: number,
w: number,
h: number,
T: {
Name: 'alpha' | 'link',
TypeInfo: {}
}
}
export declare interface Box {
x: number,
y: number,
w: number,
h: number,
oc?: string,
clr?: number
}
export declare interface Box {
id: {
Id: string,
EN?: number
}
T: {
Name: string,
TypeInfo?: {}
}
x: number,
y: number,
w: number,
h: number,
TI: number;
AM: number;
checked?: boolean;
style: number
}
export default Pdfparser