From 4a0d15aa0e4d611428a69caf5e546e1994260217 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sat, 25 Aug 2018 16:35:23 +0200 Subject: [PATCH] Slightly simplify the catalog code --- src/core/obj.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/core/obj.js b/src/core/obj.js index 5d74a250d8860..9bb26fc5dd71b 100644 --- a/src/core/obj.js +++ b/src/core/obj.js @@ -53,9 +53,9 @@ class Catalog { return shadow(this, 'metadata', null); } - const encryptMetadata = (!this.xref.encrypt ? false : - this.xref.encrypt.encryptMetadata); - const stream = this.xref.fetch(streamRef, !encryptMetadata); + const suppressEncryption = !(this.xref.encrypt && + this.xref.encrypt.encryptMetadata); + const stream = this.xref.fetch(streamRef, suppressEncryption); let metadata; if (stream && isDict(stream.dict)) { @@ -351,14 +351,11 @@ class Catalog { } get attachments() { - let attachments = null, nameTreeRef; const obj = this.catDict.get('Names'); - if (obj) { - nameTreeRef = obj.getRaw('EmbeddedFiles'); - } + let attachments = null; - if (nameTreeRef) { - const nameTree = new NameTree(nameTreeRef, this.xref); + if (obj && obj.has('EmbeddedFiles')) { + const nameTree = new NameTree(obj.getRaw('EmbeddedFiles'), this.xref); const names = nameTree.getAll(); for (const name in names) { const fs = new FileSpec(names[name], this.xref);