}
}
- // Sanity check: as per spec, first object must have these properties
- if (this.entries[0] &&
- !(this.entries[0].gen === 65535 && this.entries[0].free))
+ // Sanity check: as per spec, first object must be free
+ if (this.entries[0] && !this.entries[0].free)
error('Invalid XRef table: unexpected first object');
// Sanity check
}
// reading XRef streams
for (var i = 0, ii = xrefStms.length; i < ii; ++i) {
- this.readXRef(xrefStms[i]);
+ this.readXRef(xrefStms[i], true);
}
// finding main trailer
var dict;
// nothing helps
error('Invalid PDF structure');
},
- readXRef: function XRef_readXRef(startXRef) {
+ readXRef: function XRef_readXRef(startXRef, recoveryMode) {
var stream = this.stream;
stream.pos = startXRef;
error('Invalid XRef stream');
}
dict = this.readXRefStream(obj);
+ if (!dict)
+ error('Failed to read XRef stream');
}
// Recursively get previous dictionary, if any
obj = dict.get('Prev');
if (isInt(obj))
- this.readXRef(obj);
+ this.readXRef(obj, recoveryMode);
else if (isRef(obj)) {
// The spec says Prev must not be a reference, i.e. "/Prev NNN"
// This is a fallback for non-compliant PDFs, i.e. "/Prev NNN 0 R"
- this.readXRef(obj.num);
+ this.readXRef(obj.num, recoveryMode);
}
return dict;
log('(while reading XRef): ' + e);
}
+ if (recoveryMode)
+ return;
+
warn('Indexing all PDF objects');
return this.indexObjects();
},
"link": true,
"type": "eq"
},
+ { "id": "issue1586",
+ "file": "pdfs/issue1586.pdf",
+ "md5": "80d396cb306014b24ca82ceb68958fb5",
+ "rounds": 1,
+ "link": true,
+ "type": "load"
+ },
{ "id": "aboutstacks",
"file": "pdfs/aboutstacks.pdf",
"md5": "6e7c8416a293ba2d83bc8dd20c6ccf51",