Slightly simplify the catalog code

This commit is contained in:
Tim van der Meij 2018-08-25 16:35:23 +02:00
parent aec236f6d8
commit 4a0d15aa0e
No known key found for this signature in database
GPG Key ID: 8C3FD2925A5F2762

View File

@ -53,9 +53,9 @@ class Catalog {
return shadow(this, 'metadata', null); return shadow(this, 'metadata', null);
} }
const encryptMetadata = (!this.xref.encrypt ? false : const suppressEncryption = !(this.xref.encrypt &&
this.xref.encrypt.encryptMetadata); this.xref.encrypt.encryptMetadata);
const stream = this.xref.fetch(streamRef, !encryptMetadata); const stream = this.xref.fetch(streamRef, suppressEncryption);
let metadata; let metadata;
if (stream && isDict(stream.dict)) { if (stream && isDict(stream.dict)) {
@ -351,14 +351,11 @@ class Catalog {
} }
get attachments() { get attachments() {
let attachments = null, nameTreeRef;
const obj = this.catDict.get('Names'); const obj = this.catDict.get('Names');
if (obj) { let attachments = null;
nameTreeRef = obj.getRaw('EmbeddedFiles');
}
if (nameTreeRef) { if (obj && obj.has('EmbeddedFiles')) {
const nameTree = new NameTree(nameTreeRef, this.xref); const nameTree = new NameTree(obj.getRaw('EmbeddedFiles'), this.xref);
const names = nameTree.getAll(); const names = nameTree.getAll();
for (const name in names) { for (const name in names) {
const fs = new FileSpec(names[name], this.xref); const fs = new FileSpec(names[name], this.xref);