diff --git a/src/core/crypto.js b/src/core/crypto.js index 4074aa634..d76b6f483 100644 --- a/src/core/crypto.js +++ b/src/core/crypto.js @@ -1689,6 +1689,7 @@ const CipherTransformFactory = (function CipherTransformFactoryClosure() { if (!isName(filter, "Standard")) { throw new FormatError("unknown encryption method"); } + this.filterName = filter.name; this.dict = dict; const algorithm = dict.get("V"); if ( diff --git a/src/core/document.js b/src/core/document.js index 61f630b66..bbe3fc836 100644 --- a/src/core/document.js +++ b/src/core/document.js @@ -1161,6 +1161,9 @@ class PDFDocument { const docInfo = { PDFFormatVersion: version, Language: this.catalog.lang, + EncryptFilterName: this.xref.encrypt + ? this.xref.encrypt.filterName + : null, IsLinearized: !!this.linearization, IsAcroFormPresent: this.formInfo.hasAcroForm, IsXFAPresent: this.formInfo.hasXfa, diff --git a/src/scripting_api/doc.js b/src/scripting_api/doc.js index c3ca6e226..905f9cfec 100644 --- a/src/scripting_api/doc.js +++ b/src/scripting_api/doc.js @@ -66,6 +66,7 @@ class Doc extends PDFObject { this._numPages = data.numPages || 1; this._pageNum = data.pageNum || 0; this._producer = data.Producer || ""; + this._securityHandler = data.EncryptFilterName || null; this._subject = data.Subject || ""; this._title = data.Title || ""; this._URL = data.URL || ""; @@ -522,7 +523,7 @@ class Doc extends PDFObject { } get securityHandler() { - return null; + return this._securityHandler; } set securityHandler(_) { diff --git a/test/integration/scripting_spec.js b/test/integration/scripting_spec.js index 31ff21010..d3da48d67 100644 --- a/test/integration/scripting_spec.js +++ b/test/integration/scripting_spec.js @@ -896,4 +896,26 @@ describe("Interaction", () => { ); }); }); + + describe("in secHandler.pdf", () => { + let pages; + + beforeAll(async () => { + pages = await loadAndWait("secHandler.pdf", "#\\32 5R"); + }); + + afterAll(async () => { + await closePages(pages); + }); + it("must print securityHandler value in a text field", async () => { + await Promise.all( + pages.map(async ([browserName, page]) => { + const text = await actAndWaitForInput(page, "#\\32 5R", async () => { + await page.click("[data-annotation-id='26R']"); + }); + expect(text).withContext(`In ${browserName}`).toEqual("Standard"); + }) + ); + }); + }); }); diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 5c84ef99c..460399ac5 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -477,3 +477,4 @@ !issue12337.pdf !pr12564.pdf !pr12828.pdf +!secHandler.pdf diff --git a/test/pdfs/secHandler.pdf b/test/pdfs/secHandler.pdf new file mode 100644 index 000000000..0c761455f Binary files /dev/null and b/test/pdfs/secHandler.pdf differ diff --git a/test/unit/api_spec.js b/test/unit/api_spec.js index 2af09e5f8..bd4a7bfe5 100644 --- a/test/unit/api_spec.js +++ b/test/unit/api_spec.js @@ -1166,6 +1166,7 @@ describe("api", function () { // The following are PDF.js specific, non-standard, properties. expect(info.PDFFormatVersion).toEqual("1.7"); expect(info.Language).toEqual("en"); + expect(info.EncryptFilterName).toEqual(null); expect(info.IsLinearized).toEqual(false); expect(info.IsAcroFormPresent).toEqual(false); expect(info.IsXFAPresent).toEqual(false); @@ -1201,6 +1202,7 @@ describe("api", function () { // The following are PDF.js specific, non-standard, properties. expect(info.PDFFormatVersion).toEqual("1.4"); expect(info.Language).toEqual(null); + expect(info.EncryptFilterName).toEqual(null); expect(info.IsLinearized).toEqual(false); expect(info.IsAcroFormPresent).toEqual(false); expect(info.IsXFAPresent).toEqual(false); @@ -1223,6 +1225,7 @@ describe("api", function () { // The following are PDF.js specific, non-standard, properties. expect(info.PDFFormatVersion).toEqual(null); expect(info.Language).toEqual(null); + expect(info.EncryptFilterName).toEqual(null); expect(info.IsLinearized).toEqual(false); expect(info.IsAcroFormPresent).toEqual(false); expect(info.IsXFAPresent).toEqual(false);