mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Enable loading of PDFs with invalid document information dictionaries
This commit is contained in:
parent
99db7a8dbc
commit
d90ad429f6
3 changed files with 18 additions and 4 deletions
12
src/core.js
12
src/core.js
|
@ -457,9 +457,13 @@ var PDFDocument = (function PDFDocumentClosure() {
|
|||
PDFFormatVersion: this.pdfFormatVersion,
|
||||
IsAcroFormPresent: !!this.acroForm
|
||||
};
|
||||
if (this.xref.trailer.has('Info')) {
|
||||
var infoDict = this.xref.trailer.get('Info');
|
||||
|
||||
var infoDict;
|
||||
try {
|
||||
infoDict = this.xref.trailer.get('Info');
|
||||
} catch (err) {
|
||||
info('The document information dictionary is invalid.');
|
||||
}
|
||||
if (infoDict) {
|
||||
var validEntries = DocumentInfoValidators.entries;
|
||||
// Only fill the document info with valid entries from the spec.
|
||||
for (var key in validEntries) {
|
||||
|
@ -468,7 +472,7 @@ var PDFDocument = (function PDFDocumentClosure() {
|
|||
// Make sure the value conforms to the spec.
|
||||
if (validEntries[key](value)) {
|
||||
docInfo[key] = typeof value !== 'string' ? value :
|
||||
stringToPDFString(value);
|
||||
stringToPDFString(value);
|
||||
} else {
|
||||
info('Bad value in document info for "' + key + '"');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue