Skip to content

Commit

Permalink
catch exceptions for StartRenderPage event
Browse files Browse the repository at this point in the history
  • Loading branch information
modestysn committed Nov 20, 2021
1 parent 1271d2a commit 17ef9da
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
18 changes: 11 additions & 7 deletions base/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,17 @@ var Page = (function PageClosure() {


var opList = new OperatorList(handler, self.pageIndex);

handler.send('StartRenderPage', {
transparency: partialEvaluator.hasBlendModes(self.resources),
pageIndex: self.pageIndex
});
partialEvaluator.getOperatorList(contentStream, self.resources, opList);
pageListPromise.resolve(opList);
try {
handler.send('StartRenderPage', {
transparency: partialEvaluator.hasBlendModes(self.resources),
pageIndex: self.pageIndex
});
partialEvaluator.getOperatorList(contentStream, self.resources, opList);
pageListPromise.resolve(opList);
}
catch(e) {
pageListPromise.reject(e);
}
});

var annotationsPromise = pdfManager.ensure(this, 'annotations');
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"parse-r": "node --trace-deprecation --trace-warnings pdf2json.js -f ./test/pdf/fd/form -o ./test/target/fd/form -t -c -m -r",
"parse-242": "node --trace-deprecation --trace-warnings pdf2json.js -f ./test/pdf/misc/i242_testingWithTable.pdf -o ./test/target/misc",
"parse-e": "node --trace-deprecation --trace-warnings pdf2json.js -f ./test/pdf/misc/i43_encrypted.pdf -o ./test/target/misc",
"parse-e2": "node --trace-deprecation --trace-warnings pdf2json.js -f ./test/pdf/misc/i243_problem_file_anon.pdf -o ./test/target/misc"
"parse-e2": "node --trace-deprecation --trace-warnings pdf2json.js -f ./test/pdf/misc/i243_problem_file_anon.pdf -o ./test/target/misc",
"parse-e3": "node --trace-deprecation --trace-warnings pdf2json.js -f ./test/pdf/misc/i200_test.pdf -o ./test/target/misc"
},
"engines": {
"node": ">=14.18.0",
Expand Down
5 changes: 4 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ After install, run command line:

> npm run test-misc
It'll scan and parse 7 PDF files under *_./test/pdf/misc_*, also runs with *_-s -t -c -m_* command line options, generates primary output JSON, additional text content JSON, form fields JSON and merged text JSON file for 5 PDF fields, while catches exceptions with stack trace, one for _unsupported encryption algorithm_, another one for _Invalid XRef stream header_.
It'll scan and parse all PDF files under *_./test/pdf/misc_*, also runs with *_-s -t -c -m_* command line options, generates primary output JSON, additional text content JSON, form fields JSON and merged text JSON file for 5 PDF fields, while catches exceptions with stack trace for:
* _bad XRef entry_ for `pdf/misc/i200_test.pdf`
* _unsupported encryption algorithm_ for `pdf/misc/i43_encrypted.pdf`
* _Invalid XRef stream header_ for `pdf/misc/i243_problem_file_anon.pdf`

### Test Streams
After install, run command line:
Expand Down
Binary file added test/pdf/misc/i200_test.pdf
Binary file not shown.

0 comments on commit 17ef9da

Please sign in to comment.