interface ParserType {
    closeParser: (reParse?: boolean) => Promise<void>;
    destroy: () => Promise<void>;
    getDoc: () => Promise<null | DocType>;
    getEncryptDict: () => Promise<null | PDFDictionaryType>;
    getLastObjNum: () => Promise<number>;
    getPassword: () => Promise<string>;
    getRootObjNum: () => Promise<number>;
    getTrailer: () => Promise<null | PDFObjectType>;
    isOwner: () => Promise<boolean>;
    options?: Options;
    setPassword: (password: string) => Promise<void>;
    startParse: (fileName: string, reParse: boolean) => Promise<number>;
}

Implemented by

Properties

closeParser: (reParse?: boolean) => Promise<void>

Close the parser.

Type declaration

    • (reParse?: boolean): Promise<void>
    • Parameters

      • OptionalreParse: boolean

        Close the parser, as well as the file. If reparsing is used, the document will be kept. Default is false.

      Returns Promise<void>

destroy: () => Promise<void>

Destroy the current object.

Type declaration

    • (): Promise<void>
    • Returns Promise<void>

getDoc: () => Promise<null | DocType>

Get the document object.

Type declaration

    • (): Promise<null | DocType>
    • Returns Promise<null | DocType>

      Return the document object.

getEncryptDict: () => Promise<null | PDFDictionaryType>

Get the encrypt dictionary.

Type declaration

getLastObjNum: () => Promise<number>

Get the last object number.

Type declaration

    • (): Promise<number>
    • Returns Promise<number>

      Return the last object number.

getPassword: () => Promise<string>

Get the password.

Type declaration

    • (): Promise<string>
    • Returns Promise<string>

      Return the password.

getRootObjNum: () => Promise<number>

Get the root object number.

Type declaration

    • (): Promise<number>
    • Returns Promise<number>

      Return the root object number.

getTrailer: () => Promise<null | PDFObjectType>

Get the trailer dictionary.

Type declaration

isOwner: () => Promise<boolean>

Whether the user has the owner permission of the document.

Type declaration

    • (): Promise<boolean>
    • Returns Promise<boolean>

      Return true if the user has the owner permission of the document, otherwise return false.

options?: Options
setPassword: (password: string) => Promise<void>

Set the password.

Type declaration

    • (password: string): Promise<void>
    • Parameters

      • password: string

        The password to be set.

      Returns Promise<void>

const parser = await Parser.create();
const status = await parser.startParse('d://xxx.pdf', false);
if (status === FPD_PARSE_ERROR_PASSWORD) {
parser.setPassword('123456');
status = await parser.startParse('d://xxx.pdf', false);
}
startParse: (fileName: string, reParse: boolean) => Promise<number>

Start parse the file.

Type declaration

    • (fileName: string, reParse: boolean): Promise<number>
    • Parameters

      • fileName: string

        The file path, eg. d://xxx.pdf.

      • reParse: boolean

        Whether to re-parse, default is false.

      Returns Promise<number>

      Return the status of PDF parse. Like FPD_PARSE_ERROR_SUCCESS, FPD_PARSE_ERROR_PASSWORD, etc.

const parser = await Parser.create();
const status = await parser.startParse('d://xxx.pdf', false);
if (status === FPD_PARSE_ERROR_SUCCESS) {
console.log('Parse success');
}