diff --git a/src/core/crypto.js b/src/core/crypto.js index cfff2b8db5df4..3c9119c4f7e6c 100644 --- a/src/core/crypto.js +++ b/src/core/crypto.js @@ -1183,6 +1183,16 @@ class CipherTransformFactory { } } + getEncryptionDictionary() { + const encryptionDict = {}; + ["V", "R", "O", "U", "OE", "UE", "P"] + .forEach((key) => { + const value = this.dict.get(key); + if (value != null) encryptionDict[key] = value; + }); + return encryptionDict; + } + createCipherTransform(num, gen) { if (this.algorithm === 4 || this.algorithm === 5) { return new CipherTransform( diff --git a/src/core/document.js b/src/core/document.js index 46a2626a3a814..3f7616113239c 100644 --- a/src/core/document.js +++ b/src/core/document.js @@ -2131,6 +2131,10 @@ class ExtendedPDFDocument extends PDFDocument { get structureTree() { return shadow(this, "structureTree", this.catalog.structureTree); } + + get encryptionDictionary() { + return shadow(this, "encryptionDictionary", this.xref.getEncryptionDictionary()); + } } export { Page, ExtendedPDFDocument as PDFDocument }; diff --git a/src/core/worker.js b/src/core/worker.js index 87fe7a8fb4d3b..c5c45bf53ed42 100644 --- a/src/core/worker.js +++ b/src/core/worker.js @@ -177,10 +177,11 @@ class WorkerMessageHandler { finishWorkerTask(task); } - const [numPages, fingerprints, structureTree] = await Promise.all([ + const [numPages, fingerprints, structureTree, encryptionDictionary] = await Promise.all([ pdfManager.ensureDoc("numPages"), pdfManager.ensureDoc("fingerprints"), pdfManager.ensureDoc("structureTree"), + pdfManager.ensureDoc("encryptionDictionary"), ]); // Get htmlForXfa after numPages to avoid to create HTML twice. @@ -188,7 +189,7 @@ class WorkerMessageHandler { ? await pdfManager.ensureDoc("htmlForXfa") : null; - return { numPages, fingerprints, htmlForXfa, structureTree }; + return { numPages, fingerprints, htmlForXfa, structureTree, encryptionDictionary }; } async function getPdfManager({ diff --git a/src/core/xref.js b/src/core/xref.js index c13c08a7d3bde..d8e6cfbb07c3c 100644 --- a/src/core/xref.js +++ b/src/core/xref.js @@ -163,6 +163,10 @@ class XRef { throw new InvalidPDFException("Invalid Root reference."); } + getEncryptionDictionary() { + return this.encrypt?.getEncryptionDictionary(); + } + processXRefTable(parser) { if (!("tableState" in this)) { // Stores state of the table as we process it so we can resume