diff --git a/src/core/core.js b/src/core/core.js index c81f5b7d3..2eb8fd57b 100644 --- a/src/core/core.js +++ b/src/core/core.js @@ -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. diff --git a/test/pdfs/basicapi.pdf b/test/pdfs/basicapi.pdf index 31ffcfe9f..2f16483d5 100644 Binary files a/test/pdfs/basicapi.pdf and b/test/pdfs/basicapi.pdf differ diff --git a/test/unit/api_spec.js b/test/unit/api_spec.js index 75905f76d..2d5d17bf7 100644 --- a/test/unit/api_spec.js +++ b/test/unit/api_spec.js @@ -156,6 +156,7 @@ describe('api', function() { var promise = doc.getMetadata(); waitsForPromiseResolved(promise, function(metadata) { expect(metadata.info['Title']).toEqual('Basic API Test'); + expect(metadata.info['PDFFormatVersion']).toEqual('1.7'); expect(metadata.metadata.get('dc:title')).toEqual('Basic API Test'); }); });