Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
cb49effd19
43
src/core.js
43
src/core.js
@ -403,6 +403,24 @@ var PDFDocument = (function PDFDocumentClosure() {
|
|||||||
return true; /* found */
|
return true; /* found */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var DocumentInfoValidators = {
|
||||||
|
get entries() {
|
||||||
|
// Lazily build this since all the validation functions below are not
|
||||||
|
// defined until after this file loads.
|
||||||
|
return shadow(this, 'entries', {
|
||||||
|
Title: isString,
|
||||||
|
Author: isString,
|
||||||
|
Subject: isString,
|
||||||
|
Keywords: isString,
|
||||||
|
Creator: isString,
|
||||||
|
Producer: isString,
|
||||||
|
CreationDate: isString,
|
||||||
|
ModDate: isString,
|
||||||
|
Trapped: isName
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
PDFDocument.prototype = {
|
PDFDocument.prototype = {
|
||||||
get linearization() {
|
get linearization() {
|
||||||
var length = this.stream.length;
|
var length = this.stream.length;
|
||||||
@ -495,18 +513,27 @@ var PDFDocument = (function PDFDocumentClosure() {
|
|||||||
return shadow(this, 'numPages', num);
|
return shadow(this, 'numPages', num);
|
||||||
},
|
},
|
||||||
getDocumentInfo: function PDFDocument_getDocumentInfo() {
|
getDocumentInfo: function PDFDocument_getDocumentInfo() {
|
||||||
var info;
|
var docInfo;
|
||||||
if (this.xref.trailer.has('Info')) {
|
if (this.xref.trailer.has('Info')) {
|
||||||
var infoDict = this.xref.trailer.get('Info');
|
var infoDict = this.xref.trailer.get('Info');
|
||||||
|
|
||||||
info = {};
|
docInfo = {};
|
||||||
infoDict.forEach(function(key, value) {
|
var validEntries = DocumentInfoValidators.entries;
|
||||||
info[key] = typeof value !== 'string' ? value :
|
// Only fill the document info with valid entries from the spec.
|
||||||
stringToPDFString(value);
|
for (var key in validEntries) {
|
||||||
});
|
if (infoDict.has(key)) {
|
||||||
|
var value = infoDict.get(key);
|
||||||
|
// Make sure the value conforms to the spec.
|
||||||
|
if (validEntries[key](value)) {
|
||||||
|
docInfo[key] = typeof value !== 'string' ? value :
|
||||||
|
stringToPDFString(value);
|
||||||
|
} else {
|
||||||
|
info('Bad value in document info for "' + key + '"');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return shadow(this, 'getDocumentInfo', docInfo);
|
||||||
return shadow(this, 'getDocumentInfo', info);
|
|
||||||
},
|
},
|
||||||
getFingerprint: function PDFDocument_getFingerprint() {
|
getFingerprint: function PDFDocument_getFingerprint() {
|
||||||
var xref = this.xref, fileID;
|
var xref = this.xref, fileID;
|
||||||
|
1
test/pdfs/issue1729.pdf.link
Normal file
1
test/pdfs/issue1729.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
http://www.environmentallights.com/files/documents/ir_light_hazard.pdf
|
@ -626,5 +626,13 @@
|
|||||||
"pageLimit": 1,
|
"pageLimit": 1,
|
||||||
"link": true,
|
"link": true,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
|
},
|
||||||
|
{ "id": "issue1729",
|
||||||
|
"file": "pdfs/issue1729.pdf",
|
||||||
|
"md5": "29b0eddc3e1dcb23a44384037032d470",
|
||||||
|
"rounds": 1,
|
||||||
|
"pageLimit": 1,
|
||||||
|
"link": true,
|
||||||
|
"type": "load"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user