diff --git a/src/core/document.js b/src/core/document.js index 3076490dc..4513ae71d 100644 --- a/src/core/document.js +++ b/src/core/document.js @@ -600,19 +600,6 @@ class PDFDocument { info("Cannot fetch AcroForm entry; assuming no AcroForms are present"); 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.size > 0) { - this.collection = collection; - } - } catch (ex) { - if (ex instanceof MissingDataException) { - throw ex; - } - info("Cannot fetch Collection dictionary."); - } } get linearization() { @@ -745,7 +732,7 @@ class PDFDocument { IsLinearized: !!this.linearization, IsAcroFormPresent: !!this.acroForm, IsXFAPresent: !!this.xfa, - IsCollectionPresent: !!this.collection, + IsCollectionPresent: !!this.catalog.collection, }; let infoDict; diff --git a/src/core/obj.js b/src/core/obj.js index 47dcd902b..eaf885a7f 100644 --- a/src/core/obj.js +++ b/src/core/obj.js @@ -84,6 +84,22 @@ class Catalog { return shadow(this, "version", version.name); } + get collection() { + let collection = null; + try { + const obj = this.catDict.get("Collection"); + if (isDict(obj) && obj.size > 0) { + collection = obj; + } + } catch (ex) { + if (ex instanceof MissingDataException) { + throw ex; + } + info("Cannot fetch Collection entry; assuming no collection is present."); + } + return shadow(this, "collection", collection); + } + get metadata() { const streamRef = this.catDict.getRaw("Metadata"); if (!isRef(streamRef)) {