mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 10:15:37 +02:00
Merge pull request #3376 from yurydelendik/bad-pdfs
Misc fixes for corrupted PDFs
This commit is contained in:
commit
f06dadab3b
5 changed files with 71 additions and 7 deletions
21
src/obj.js
21
src/obj.js
|
@ -266,6 +266,18 @@ var Catalog = (function CatalogClosure() {
|
|||
return shadow(this, 'toplevelPagesDict', pagesObj);
|
||||
},
|
||||
get documentOutline() {
|
||||
var obj = null;
|
||||
try {
|
||||
obj = this.readDocumentOutline();
|
||||
} catch (ex) {
|
||||
if (ex instanceof MissingDataException) {
|
||||
throw ex;
|
||||
}
|
||||
warn('Unable to read document outline');
|
||||
}
|
||||
return shadow(this, 'documentOutline', obj);
|
||||
},
|
||||
readDocumentOutline: function Catalog_readDocumentOutline() {
|
||||
var xref = this.xref;
|
||||
var obj = this.catDict.get('Outlines');
|
||||
var root = { items: [] };
|
||||
|
@ -316,8 +328,7 @@ var Catalog = (function CatalogClosure() {
|
|||
}
|
||||
}
|
||||
}
|
||||
obj = root.items.length > 0 ? root.items : null;
|
||||
return shadow(this, 'documentOutline', obj);
|
||||
return root.items.length > 0 ? root.items : null;
|
||||
},
|
||||
get numPages() {
|
||||
var obj = this.toplevelPagesDict.get('Count');
|
||||
|
@ -598,6 +609,12 @@ var XRef = (function XRefClosure() {
|
|||
delete tableState.entryCount;
|
||||
}
|
||||
|
||||
// Per issue 3248: hp scanners generate bad XRef
|
||||
if (first === 1 && this.entries[1] && this.entries[1].free) {
|
||||
// shifting the entries
|
||||
this.entries.shift();
|
||||
}
|
||||
|
||||
// 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');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue