Skip to content

Commit 04b58cb

Browse files
committed
[api-minor] Implement securityHandler in the scripting API (bug 1731578)
1 parent 1ab9a6e commit 04b58cb

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

src/core/crypto.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,6 +1689,7 @@ const CipherTransformFactory = (function CipherTransformFactoryClosure() {
16891689
if (!isName(filter, "Standard")) {
16901690
throw new FormatError("unknown encryption method");
16911691
}
1692+
this.filterName = filter.name;
16921693
this.dict = dict;
16931694
const algorithm = dict.get("V");
16941695
if (

src/core/document.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,9 @@ class PDFDocument {
11621162
PDFFormatVersion: version,
11631163
Language: this.catalog.lang,
11641164
IsLinearized: !!this.linearization,
1165+
EncryptFilterName: this.xref.encrypt
1166+
? this.xref.encrypt.filterName
1167+
: null,
11651168
IsAcroFormPresent: this.formInfo.hasAcroForm,
11661169
IsXFAPresent: this.formInfo.hasXfa,
11671170
IsCollectionPresent: !!this.catalog.collection,

src/scripting_api/doc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class Doc extends PDFObject {
6666
this._numPages = data.numPages || 1;
6767
this._pageNum = data.pageNum || 0;
6868
this._producer = data.Producer || "";
69+
this._securityHandler = data.EncryptFilterName || null;
6970
this._subject = data.Subject || "";
7071
this._title = data.Title || "";
7172
this._URL = data.URL || "";
@@ -522,7 +523,7 @@ class Doc extends PDFObject {
522523
}
523524

524525
get securityHandler() {
525-
return null;
526+
return this._securityHandler;
526527
}
527528

528529
set securityHandler(_) {

test/unit/api_spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,7 @@ describe("api", function () {
11661166
// The following are PDF.js specific, non-standard, properties.
11671167
expect(info.PDFFormatVersion).toEqual("1.7");
11681168
expect(info.Language).toEqual("en");
1169+
expect(info.EncryptFilterName).toEqual(null);
11691170
expect(info.IsLinearized).toEqual(false);
11701171
expect(info.IsAcroFormPresent).toEqual(false);
11711172
expect(info.IsXFAPresent).toEqual(false);
@@ -1201,6 +1202,7 @@ describe("api", function () {
12011202
// The following are PDF.js specific, non-standard, properties.
12021203
expect(info.PDFFormatVersion).toEqual("1.4");
12031204
expect(info.Language).toEqual(null);
1205+
expect(info.EncryptFilterName).toEqual(null);
12041206
expect(info.IsLinearized).toEqual(false);
12051207
expect(info.IsAcroFormPresent).toEqual(false);
12061208
expect(info.IsXFAPresent).toEqual(false);
@@ -1223,6 +1225,7 @@ describe("api", function () {
12231225
// The following are PDF.js specific, non-standard, properties.
12241226
expect(info.PDFFormatVersion).toEqual(null);
12251227
expect(info.Language).toEqual(null);
1228+
expect(info.EncryptFilterName).toEqual(null);
12261229
expect(info.IsLinearized).toEqual(false);
12271230
expect(info.IsAcroFormPresent).toEqual(false);
12281231
expect(info.IsXFAPresent).toEqual(false);

0 commit comments

Comments
 (0)