Enable loading of PDFs with invalid document information dictionaries
This commit is contained in:
parent
99db7a8dbc
commit
d90ad429f6
12
src/core.js
12
src/core.js
@ -457,9 +457,13 @@ var PDFDocument = (function PDFDocumentClosure() {
|
|||||||
PDFFormatVersion: this.pdfFormatVersion,
|
PDFFormatVersion: this.pdfFormatVersion,
|
||||||
IsAcroFormPresent: !!this.acroForm
|
IsAcroFormPresent: !!this.acroForm
|
||||||
};
|
};
|
||||||
if (this.xref.trailer.has('Info')) {
|
var infoDict;
|
||||||
var infoDict = this.xref.trailer.get('Info');
|
try {
|
||||||
|
infoDict = this.xref.trailer.get('Info');
|
||||||
|
} catch (err) {
|
||||||
|
info('The document information dictionary is invalid.');
|
||||||
|
}
|
||||||
|
if (infoDict) {
|
||||||
var validEntries = DocumentInfoValidators.entries;
|
var validEntries = DocumentInfoValidators.entries;
|
||||||
// Only fill the document info with valid entries from the spec.
|
// Only fill the document info with valid entries from the spec.
|
||||||
for (var key in validEntries) {
|
for (var key in validEntries) {
|
||||||
@ -468,7 +472,7 @@ var PDFDocument = (function PDFDocumentClosure() {
|
|||||||
// Make sure the value conforms to the spec.
|
// Make sure the value conforms to the spec.
|
||||||
if (validEntries[key](value)) {
|
if (validEntries[key](value)) {
|
||||||
docInfo[key] = typeof value !== 'string' ? value :
|
docInfo[key] = typeof value !== 'string' ? value :
|
||||||
stringToPDFString(value);
|
stringToPDFString(value);
|
||||||
} else {
|
} else {
|
||||||
info('Bad value in document info for "' + key + '"');
|
info('Bad value in document info for "' + key + '"');
|
||||||
}
|
}
|
||||||
|
1
test/pdfs/issue2853.pdf.link
Normal file
1
test/pdfs/issue2853.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
http://www.celgene.de/Patienten/Newsletter-Epigenetik-201301.pdf
|
@ -1310,5 +1310,14 @@
|
|||||||
"firstPage": 1,
|
"firstPage": 1,
|
||||||
"lastPage": 1,
|
"lastPage": 1,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
|
},
|
||||||
|
{ "id": "issue2853",
|
||||||
|
"file": "pdfs/issue2853.pdf",
|
||||||
|
"md5": "9f0ad95ef0b243ee8813c4eca0f7a042",
|
||||||
|
"rounds": 1,
|
||||||
|
"link": true,
|
||||||
|
"firstPage": 1,
|
||||||
|
"lastPage": 1,
|
||||||
|
"type": "load"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user