Skip to content

Commit 17ef9da

Browse files
committed
catch exceptions for StartRenderPage event
1 parent 1271d2a commit 17ef9da

4 files changed

Lines changed: 17 additions & 9 deletions

File tree

base/core/core.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,17 @@ var Page = (function PageClosure() {
170170

171171

172172
var opList = new OperatorList(handler, self.pageIndex);
173-
174-
handler.send('StartRenderPage', {
175-
transparency: partialEvaluator.hasBlendModes(self.resources),
176-
pageIndex: self.pageIndex
177-
});
178-
partialEvaluator.getOperatorList(contentStream, self.resources, opList);
179-
pageListPromise.resolve(opList);
173+
try {
174+
handler.send('StartRenderPage', {
175+
transparency: partialEvaluator.hasBlendModes(self.resources),
176+
pageIndex: self.pageIndex
177+
});
178+
partialEvaluator.getOperatorList(contentStream, self.resources, opList);
179+
pageListPromise.resolve(opList);
180+
}
181+
catch(e) {
182+
pageListPromise.reject(e);
183+
}
180184
});
181185

182186
var annotationsPromise = pdfManager.ensure(this, 'annotations');

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
"parse-r": "node --trace-deprecation --trace-warnings pdf2json.js -f ./test/pdf/fd/form -o ./test/target/fd/form -t -c -m -r",
3838
"parse-242": "node --trace-deprecation --trace-warnings pdf2json.js -f ./test/pdf/misc/i242_testingWithTable.pdf -o ./test/target/misc",
3939
"parse-e": "node --trace-deprecation --trace-warnings pdf2json.js -f ./test/pdf/misc/i43_encrypted.pdf -o ./test/target/misc",
40-
"parse-e2": "node --trace-deprecation --trace-warnings pdf2json.js -f ./test/pdf/misc/i243_problem_file_anon.pdf -o ./test/target/misc"
40+
"parse-e2": "node --trace-deprecation --trace-warnings pdf2json.js -f ./test/pdf/misc/i243_problem_file_anon.pdf -o ./test/target/misc",
41+
"parse-e3": "node --trace-deprecation --trace-warnings pdf2json.js -f ./test/pdf/misc/i200_test.pdf -o ./test/target/misc"
4142
},
4243
"engines": {
4344
"node": ">=14.18.0",

readme.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ After install, run command line:
3131

3232
> npm run test-misc
3333
34-
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_.
34+
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:
35+
* _bad XRef entry_ for `pdf/misc/i200_test.pdf`
36+
* _unsupported encryption algorithm_ for `pdf/misc/i43_encrypted.pdf`
37+
* _Invalid XRef stream header_ for `pdf/misc/i243_problem_file_anon.pdf`
3538

3639
### Test Streams
3740
After install, run command line:

test/pdf/misc/i200_test.pdf

60.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)