mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 01:58:06 +02:00
Extract correct PDF format version from the catalog
The 'Version' field of the most recent document catalog, if present, is intended to supersede the value in the file prologue. This is significant for incrementally-built PDF documents and generators that emit a low version in the prologue and later apply a format version based on PDF features used, such as Apple's CoreGraphics/Quartz PDF backend. Fixes the internal version variable, as well as the PDFFormatVersion reported by the API and consumed by viewers.
This commit is contained in:
parent
82536f8fa6
commit
4c9b65f0e1
3 changed files with 9 additions and 2 deletions
|
@ -343,6 +343,10 @@ var PDFDocument = (function PDFDocumentClosure() {
|
|||
PDFDocument.prototype = {
|
||||
parse: function PDFDocument_parse(recoveryMode) {
|
||||
this.setup(recoveryMode);
|
||||
var version = this.catalog.catDict.get('Version');
|
||||
if (isName(version)) {
|
||||
this.pdfFormatVersion = version.name;
|
||||
}
|
||||
try {
|
||||
// checking if AcroForm is present
|
||||
this.acroForm = this.catalog.catDict.get('AcroForm');
|
||||
|
@ -444,8 +448,10 @@ var PDFDocument = (function PDFDocumentClosure() {
|
|||
}
|
||||
version += String.fromCharCode(ch);
|
||||
}
|
||||
// removing "%PDF-"-prefix
|
||||
this.pdfFormatVersion = version.substring(5);
|
||||
if (!this.pdfFormatVersion) {
|
||||
// removing "%PDF-"-prefix
|
||||
this.pdfFormatVersion = version.substring(5);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// May not be a PDF file, continue anyway.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue