Skip to content

Commit

Permalink
Slightly simplify the catalog code
Browse files Browse the repository at this point in the history
  • Loading branch information
timvandermeij committed Aug 25, 2018
1 parent aec236f commit 4a0d15a
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/core/obj.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 4a0d15a

Please sign in to comment.