If readXRefStream or readXRefTable fails, fallback to object indexing (#828)
This commit is contained in:
parent
c0291e9fa3
commit
0f7f80ee6e
29
src/obj.js
29
src/obj.js
@ -518,20 +518,25 @@ 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;
|
||||||
var parser = new Parser(new Lexer(stream), true);
|
try {
|
||||||
var obj = parser.getObj();
|
var parser = new Parser(new Lexer(stream), true);
|
||||||
// parse an old-style xref table
|
var obj = parser.getObj();
|
||||||
if (isCmd(obj, 'xref'))
|
// parse an old-style xref table
|
||||||
return this.readXRefTable(parser);
|
if (isCmd(obj, 'xref'))
|
||||||
// parse an xref stream
|
return this.readXRefTable(parser);
|
||||||
if (isInt(obj)) {
|
// parse an xref stream
|
||||||
if (!isInt(parser.getObj()) ||
|
if (isInt(obj)) {
|
||||||
!isCmd(parser.getObj(), 'obj') ||
|
if (!isInt(parser.getObj()) ||
|
||||||
!isStream(obj = parser.getObj())) {
|
!isCmd(parser.getObj(), 'obj') ||
|
||||||
error('Invalid XRef stream');
|
!isStream(obj = parser.getObj())) {
|
||||||
|
error('Invalid XRef stream');
|
||||||
|
}
|
||||||
|
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) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user