-
Notifications
You must be signed in to change notification settings - Fork 377
/
Copy pathpdfparser.d.ts
149 lines (132 loc) · 3.29 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/* eslint-disable @typescript-eslint/no-explicit-any */
import { EventEmitter } from "node:events";
import { Transform, Readable, TransformOptions, TransformCallback } from "node:stream";
import fs from "node:fs";
export declare class StringifyStream extends Transform {
constructor(options?: TransformOptions);
_transform(obj: any, encoding: string, callback: TransformCallback): void;
}
export declare class ParserStream{
static createContentStream(jsonObj): Readable
static createOutputStream(outputPath, resolve, reject): fs.WriteStream
}
export declare class PDFParser extends EventEmitter{
static get ParserStream(): typeof ParserStream
static get StringifyStream(): typeof StringifyStream
static get pkInfo(): { version: string; name: string; description: string; author: string; license: string; }
// eslint-disable-next-line @typescript-eslint/naming-convention
static get _PARSER_SIG(): string
constructor(context?: any, needRawText?: boolean, password?: string);
parseBuffer(buffer: Buffer, verbosity?: number): void;
loadPDF(pdfFilePath: string, verbosity?: number):Promise<void>
createParserStream(): ParserStream
getRawTextContent(): string
on<K extends keyof EventMap>(eventName: K, listener: EventMap[K]): this
}
export type EventMap = {
// eslint-disable-next-line @typescript-eslint/naming-convention
"pdfParser_dataError": (errMsg: Record<"parserError", Error>) => void;
// eslint-disable-next-line @typescript-eslint/naming-convention
"pdfParser_dataReady": (pdfData: Output) => void;
"readable": (meta: Output["Meta"]) => void;
"data": (data: Output["Pages"][number]|null) => void;
}
export interface Output{
Transcoder: string,
Meta: Record<string, object>
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,
l: 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: object
}
}
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? : object
}
x: number,
y: number,
w: number,
h: number,
TI: number;
AM: number;
checked?: boolean;
style: number
}
export default PDFParser