Merge pull request #10556 from Snuffleupagus/documentInfo-collection
[api-minor] Expose the existence of a `Collection` dictionary via the `getMetadata` API method (issue 10555)
This commit is contained in:
commit
50afff9918
@ -401,8 +401,7 @@ class PDFDocument {
|
|||||||
if (this.acroForm) {
|
if (this.acroForm) {
|
||||||
this.xfa = this.acroForm.get('XFA');
|
this.xfa = this.acroForm.get('XFA');
|
||||||
const fields = this.acroForm.get('Fields');
|
const fields = this.acroForm.get('Fields');
|
||||||
if ((!fields || !Array.isArray(fields) || fields.length === 0) &&
|
if ((!Array.isArray(fields) || fields.length === 0) && !this.xfa) {
|
||||||
!this.xfa) {
|
|
||||||
this.acroForm = null; // No fields and no XFA, so it's not a form.
|
this.acroForm = null; // No fields and no XFA, so it's not a form.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -413,6 +412,19 @@ class PDFDocument {
|
|||||||
info('Cannot fetch AcroForm entry; assuming no AcroForms are present');
|
info('Cannot fetch AcroForm entry; assuming no AcroForms are present');
|
||||||
this.acroForm = null;
|
this.acroForm = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if a Collection dictionary is present in the document.
|
||||||
|
try {
|
||||||
|
const collection = this.catalog.catDict.get('Collection');
|
||||||
|
if (isDict(collection) && collection.getKeys().length > 0) {
|
||||||
|
this.collection = collection;
|
||||||
|
}
|
||||||
|
} catch (ex) {
|
||||||
|
if (ex instanceof MissingDataException) {
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
info('Cannot fetch Collection dictionary.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get linearization() {
|
get linearization() {
|
||||||
@ -534,6 +546,7 @@ class PDFDocument {
|
|||||||
IsLinearized: !!this.linearization,
|
IsLinearized: !!this.linearization,
|
||||||
IsAcroFormPresent: !!this.acroForm,
|
IsAcroFormPresent: !!this.acroForm,
|
||||||
IsXFAPresent: !!this.xfa,
|
IsXFAPresent: !!this.xfa,
|
||||||
|
IsCollectionPresent: !!this.collection,
|
||||||
};
|
};
|
||||||
|
|
||||||
let infoDict;
|
let infoDict;
|
||||||
|
@ -846,6 +846,7 @@ describe('api', function() {
|
|||||||
expect(info['IsLinearized']).toEqual(false);
|
expect(info['IsLinearized']).toEqual(false);
|
||||||
expect(info['IsAcroFormPresent']).toEqual(false);
|
expect(info['IsAcroFormPresent']).toEqual(false);
|
||||||
expect(info['IsXFAPresent']).toEqual(false);
|
expect(info['IsXFAPresent']).toEqual(false);
|
||||||
|
expect(info['IsCollectionPresent']).toEqual(false);
|
||||||
|
|
||||||
expect(metadata instanceof Metadata).toEqual(true);
|
expect(metadata instanceof Metadata).toEqual(true);
|
||||||
expect(metadata.get('dc:title')).toEqual('Basic API Test');
|
expect(metadata.get('dc:title')).toEqual('Basic API Test');
|
||||||
@ -874,6 +875,7 @@ describe('api', function() {
|
|||||||
expect(info['IsLinearized']).toEqual(false);
|
expect(info['IsLinearized']).toEqual(false);
|
||||||
expect(info['IsAcroFormPresent']).toEqual(false);
|
expect(info['IsAcroFormPresent']).toEqual(false);
|
||||||
expect(info['IsXFAPresent']).toEqual(false);
|
expect(info['IsXFAPresent']).toEqual(false);
|
||||||
|
expect(info['IsCollectionPresent']).toEqual(false);
|
||||||
|
|
||||||
expect(metadata).toEqual(null);
|
expect(metadata).toEqual(null);
|
||||||
expect(contentDispositionFilename).toEqual(null);
|
expect(contentDispositionFilename).toEqual(null);
|
||||||
|
Loading…
Reference in New Issue
Block a user