Merge pull request #862 from notmasteryet/issue-828

Fallback to object indexing when reading of xref fails (#828)
This commit is contained in:
Artur Adib 2011-12-05 09:06:53 -08:00
commit e44521eae3

View File

@ -518,11 +518,15 @@ var XRef = (function xRefXRef() {
readXRef: function readXref(startXRef) { readXRef: function readXref(startXRef) {
var stream = this.stream; var stream = this.stream;
stream.pos = startXRef; stream.pos = startXRef;
try {
var parser = new Parser(new Lexer(stream), true); var parser = new Parser(new Lexer(stream), true);
var obj = parser.getObj(); var obj = parser.getObj();
// parse an old-style xref table // parse an old-style xref table
if (isCmd(obj, 'xref')) if (isCmd(obj, 'xref'))
return this.readXRefTable(parser); return this.readXRefTable(parser);
// parse an xref stream // parse an xref stream
if (isInt(obj)) { if (isInt(obj)) {
if (!isInt(parser.getObj()) || if (!isInt(parser.getObj()) ||
@ -532,6 +536,11 @@ var XRef = (function xRefXRef() {
} }
return this.readXRefStream(obj); return this.readXRefStream(obj);
} }
} catch (e) {
log('Reading of the xref table/stream failed: ' + e);
}
warn('Indexing all PDF objects');
return this.indexObjects(); return this.indexObjects();
}, },
getEntry: function xRefGetEntry(i) { getEntry: function xRefGetEntry(i) {