diff --git a/src/core/document.js b/src/core/document.js index dfc46df98..df243e1bb 100644 --- a/src/core/document.js +++ b/src/core/document.js @@ -535,12 +535,13 @@ var PDFDocument = (function PDFDocumentClosure() { return shadow(this, 'numPages', num); }, get documentInfo() { - var docInfo = { + const docInfo = { PDFFormatVersion: this.pdfFormatVersion, + IsLinearized: !!this.linearization, IsAcroFormPresent: !!this.acroForm, IsXFAPresent: !!this.xfa, }; - var infoDict; + let infoDict; try { infoDict = this.xref.trailer.get('Info'); } catch (err) { diff --git a/test/unit/api_spec.js b/test/unit/api_spec.js index 2f79d4cc3..1a643e0ae 100644 --- a/test/unit/api_spec.js +++ b/test/unit/api_spec.js @@ -28,6 +28,7 @@ import { } from '../../src/display/api'; import { GlobalWorkerOptions } from '../../src/display/worker_options'; import isNodeJS from '../../src/shared/is_node'; +import { Metadata } from '../../src/display/metadata'; describe('api', function() { let basicApiFileName = 'basicapi.pdf'; @@ -802,11 +803,18 @@ describe('api', function() { }); it('gets metadata', function(done) { var promise = doc.getMetadata(); - promise.then(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'); - expect(metadata.contentDispositionFilename).toEqual(null); + promise.then(function({ info, metadata, contentDispositionFilename, }) { + expect(info['Title']).toEqual('Basic API Test'); + // The following are PDF.js specific, non-standard, properties. + expect(info['PDFFormatVersion']).toEqual('1.7'); + expect(info['IsLinearized']).toEqual(false); + expect(info['IsAcroFormPresent']).toEqual(false); + expect(info['IsXFAPresent']).toEqual(false); + + expect(metadata instanceof Metadata).toEqual(true); + expect(metadata.get('dc:title')).toEqual('Basic API Test'); + + expect(contentDispositionFilename).toEqual(null); done(); }).catch(function (reason) { done.fail(reason);