Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/core/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions src/core/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
5 changes: 3 additions & 2 deletions src/core/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,19 @@ 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.
const htmlForXfa = isPureXfa
? await pdfManager.ensureDoc("htmlForXfa")
: null;

return { numPages, fingerprints, htmlForXfa, structureTree };
return { numPages, fingerprints, htmlForXfa, structureTree, encryptionDictionary };
}

async function getPdfManager({
Expand Down
4 changes: 4 additions & 0 deletions src/core/xref.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading