Skip to content

Commit

Permalink
resolve conflicts in package.json for pdfparser.d.ts branch
Browse files Browse the repository at this point in the history
  • Loading branch information
modesty committed Feb 18, 2023
2 parents 6fb91c9 + 7570ec2 commit a04ce60
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 3 deletions.
16 changes: 15 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
"url": "git://github.com/modesty/pdf2json.git"
},
"main": "./pdfparser.js",
"typings": "./pdfparser.d.ts",
"scripts": {
"test": "cd ./test && sh p2j.forms.sh",
"test-misc": "cd ./test && sh p2j.one.sh misc . \"Expected: 5 success, 3 exception with stack trace\" ",
"test-misc": "cd ./test && sh p2j.one.sh misc . \"Expected: 6 success, 3 fail exception with stack trace\" ",
"parse": "node --trace-deprecation --trace-warnings pdf2json.js -f ./test/pdf/fd/form/F1040.pdf -o ./test/target/fd/form",
"parse-s": "node --trace-deprecation --trace-warnings pdf2json.js -f ./test/pdf/fd/form/F1040.pdf -o ./test/target/fd/form -s",
"parse-t": "node --trace-deprecation --trace-warnings pdf2json.js -f ./test/pdf/fd/form/F1040.pdf -o ./test/target/fd/form -s -t",
Expand All @@ -54,7 +55,9 @@
"dependencies": {
"@xmldom/xmldom": "^0.8.6"
},
"devDependencies": {},
"devDependencies": {
"@types/node": "^18.7.18"
},
"bundledDependencies": [
"@xmldom/xmldom"
],
Expand Down
130 changes: 130 additions & 0 deletions pdfparser.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import {EventEmitter} from "events";

declare class Pdfparser extends EventEmitter{
constructor();
parseBuffer(buffer: Buffer): void;
loadPDF(pdfFilePath: string, verbosity?: number):Promise<void>
createParserStream():ParserStream
on<K extends keyof EventMap>(eventName: K, listener: EventMap[K]): this
}

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[]
}

declare interface Page{
Width: number,
Height: number,
HLines: Line[],
VLines: Line[],
Fills: Fill[],
Texts: Text[],
Fields: Field[],
Boxsets: Boxset[]
}

declare interface Fill {
x: number,
y: number,
w: number,
h: number,
oc?: string,
clr?: number
}

declare interface Line {
x: number,
y: number,
w: number,
oc?: string,
clr?:number
}

declare interface Text {
x: number,
y: number,
w: number,
sw: number,
A: 'left' | 'center' | 'right',
R: TextRun[]
oc?:string;
clr?: number;
}

declare interface TextRun {
T: string,
S: number,
TS: [number, number, 0|1, 0|1]
RA?: number
}

declare interface Boxset {
boxes: Box[],
id : {
Id: string,
EN?: number
}
}

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: {}
}
}

declare interface Box {
x: number,
y: number,
w: number,
h: number,
oc?: string,
clr?: number
}

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

0 comments on commit a04ce60

Please sign in to comment.