Skip to content

Commit 9de9499

Browse files
committed
Catch errors when parsing the linearization header so we can display corrupted docs
1 parent c757eed commit 9de9499

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/core.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,16 @@ var PDFDocument = (function PDFDocumentClosure() {
398398
get linearization() {
399399
var length = this.stream.length;
400400
var linearization = false;
401-
if (length) {
402-
linearization = new Linearization(this.stream);
403-
if (linearization.length != length)
404-
linearization = false;
401+
try {
402+
if (length) {
403+
linearization = new Linearization(this.stream);
404+
if (linearization.length != length)
405+
linearization = false;
406+
}
407+
} catch (err) {
408+
warn('since pdf is broken pdf.js is trying to recover it ' +
409+
'by indexing the object; ' +
410+
'the error in firebug shall have a different origin');
405411
}
406412
// shadow the prototype getter with a data property
407413
return shadow(this, 'linearization', linearization);

0 commit comments

Comments
 (0)