@@ -16,7 +16,7 @@ And I use this name to hope the merits from this application will be dedicated t
16
16
* 128bit AES Encryption
17
17
* 256bit AES Encryption
18
18
* Set public-key certificate protection to a pdf.
19
- Supported algorithms are same as the password protection.
19
+ Supported algorithms are as same as the password protection.
20
20
21
21
## About signing with TSA
22
22
@@ -122,6 +122,7 @@ eval(UrlFetchApp.fetch("https://github.com/zboris12/zgapdfsigner/releases/downlo
122
122
var pdfBlob = DriveApp .getFilesByName (" _test.pdf" ).next ().getBlob ();
123
123
var certBlob = DriveApp .getFilesByName (" _test.pfx" ).next ().getBlob ();
124
124
// Sign the pdf
125
+ /** @type {SignOption} */
125
126
var sopt = {
126
127
p12cert: certBlob .getBytes (),
127
128
pwd: " some passphrase" ,
@@ -181,7 +182,7 @@ Set password protection to the pdf.
181
182
async function protect1 (pdf , upwd , opwd ){
182
183
/** @type {EncryptOption} */
183
184
var eopt = {
184
- mode: Zga .Crypto .Mode .AES_256 ,
185
+ mode: Zga .Crypto .Mode .RC4_40 ,
185
186
permissions: [" modify" , " annot-forms" , " fill-forms" , " extract" , " assemble" ],
186
187
userpwd: upwd,
187
188
ownerpwd: opwd,
@@ -201,7 +202,7 @@ Set public-key certificate protection to the pdf.
201
202
* @param {ArrayBuffer} cert
202
203
* @return {Promise<Blob>}
203
204
*/
204
- async function protect1 (pdf , cert ){
205
+ async function protect2 (pdf , cert ){
205
206
/** @type {EncryptOption} */
206
207
var eopt = {
207
208
mode: Zga .Crypto .Mode .AES_128 ,
@@ -227,7 +228,7 @@ Sign and set protection.
227
228
* @param {string} opwd
228
229
* @return {Promise<Blob>}
229
230
*/
230
- async function sign1 (pdf , cert , pwd , opwd ){
231
+ async function signAndProtect1 (pdf , cert , pwd , opwd ){
231
232
/** @type {SignOption} */
232
233
var sopt = {
233
234
p12cert: cert,
@@ -245,14 +246,41 @@ async function sign1(pdf, cert, pwd, opwd){
245
246
}
246
247
```
247
248
249
+ Sign and set protection by the same certificate.
250
+
251
+ ``` js
252
+ /**
253
+ * @param {ArrayBuffer} pdf
254
+ * @param {ArrayBuffer} cert
255
+ * @param {string} pwd
256
+ * @return {Promise<Blob>}
257
+ */
258
+ async function signAndProtect2 (pdf , cert , pwd ){
259
+ /** @type {SignOption} */
260
+ var sopt = {
261
+ p12cert: cert,
262
+ pwd: pwd,
263
+ };
264
+ /** @type {EncryptOption} */
265
+ var eopt = {
266
+ mode: Zga .Crypto .Mode .AES_256 ,
267
+ permissions: [" modify" , " annot-forms" , " fill-forms" , " extract" , " assemble" ],
268
+ pubkeys: [],
269
+ };
270
+ var signer = new Zga.PdfSigner (sopt);
271
+ var u8arr = await signer .sign (pdf, eopt);
272
+ return new Blob ([u8arr], {" type" : " application/pdf" });
273
+ }
274
+ ```
275
+
248
276
## Detail of EncryptOption
249
277
250
278
* __ mode__ : Zga.Crypto.Mode :point_right : The values of Zga.Crypto.Mode
251
279
* RC4_40: 40bit RC4 Encryption
252
280
* RC4_128: 128bit RC4 Encryption
253
281
* AES_128: 128bit AES Encryption
254
282
* AES_256: 256bit AES Encryption
255
- * __ permissions__ : Array<string > :point_right : (Optional) The set of permissions you want to block
283
+ * __ permissions__ : Array<string > :point_right : (Optional) The set of permissions to be blocked
256
284
* "copy": (Only valid on public-key mode) Copy text and graphics from the document;
257
285
* "print": Print the document;
258
286
* "modify": Modify the contents of the document by operations other than those controlled by 'fill-forms', 'extract' and 'assemble';
0 commit comments