mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 09:38:06 +02:00
When parsing corrupt documents without any trailer-dictionary, fallback to the "top"-dictionary (issue 14269)
There's obviously no guarantee that this will work in general, if the document is sufficiently corrupt, but it should hopefully be better than just throwing `InvalidPDFException` as currently happens. Please note that, as is often the case with corrupt documents, it's somewhat difficult to know if we're rendering the document "correctly" with this patch[1]. In this case even Adobe Reader cannot open the document, which is always a good sign that it's *really* corrupt, however we're at least able to render *something* with this patch. --- [1] Whatever "correct" even means when dealing with corrupt PDF documents, where often times different PDF viewers won't agree completely.
This commit is contained in:
parent
28fb3975eb
commit
afcc99a86d
3 changed files with 15 additions and 0 deletions
|
@ -590,6 +590,10 @@ class XRef {
|
|||
if (trailerDict) {
|
||||
return trailerDict;
|
||||
}
|
||||
// No trailer dictionary found, taking the "top"-dictionary (if exists).
|
||||
if (this.topDict) {
|
||||
return this.topDict;
|
||||
}
|
||||
// nothing helps
|
||||
throw new InvalidPDFException("Invalid PDF structure.");
|
||||
}
|
||||
|
@ -680,6 +684,8 @@ class XRef {
|
|||
throw e;
|
||||
}
|
||||
info("(while reading XRef): " + e);
|
||||
|
||||
this.startXRefQueue.shift();
|
||||
}
|
||||
|
||||
if (recoveryMode) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue