Skip to content

Commit adc260b

Browse files
committed
Improved the readme.
1 parent 299aeb3 commit adc260b

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

README.md

+33-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ And I use this name to hope the merits from this application will be dedicated t
1616
* 128bit AES Encryption
1717
* 256bit AES Encryption
1818
* 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.
2020

2121
## About signing with TSA
2222

@@ -122,6 +122,7 @@ eval(UrlFetchApp.fetch("https://github.com/zboris12/zgapdfsigner/releases/downlo
122122
var pdfBlob = DriveApp.getFilesByName("_test.pdf").next().getBlob();
123123
var certBlob = DriveApp.getFilesByName("_test.pfx").next().getBlob();
124124
// Sign the pdf
125+
/** @type {SignOption} */
125126
var sopt = {
126127
p12cert: certBlob.getBytes(),
127128
pwd: "some passphrase",
@@ -181,7 +182,7 @@ Set password protection to the pdf.
181182
async function protect1(pdf, upwd, opwd){
182183
/** @type {EncryptOption} */
183184
var eopt = {
184-
mode: Zga.Crypto.Mode.AES_256,
185+
mode: Zga.Crypto.Mode.RC4_40,
185186
permissions: ["modify", "annot-forms", "fill-forms", "extract", "assemble"],
186187
userpwd: upwd,
187188
ownerpwd: opwd,
@@ -201,7 +202,7 @@ Set public-key certificate protection to the pdf.
201202
* @param {ArrayBuffer} cert
202203
* @return {Promise<Blob>}
203204
*/
204-
async function protect1(pdf, cert){
205+
async function protect2(pdf, cert){
205206
/** @type {EncryptOption} */
206207
var eopt = {
207208
mode: Zga.Crypto.Mode.AES_128,
@@ -227,7 +228,7 @@ Sign and set protection.
227228
* @param {string} opwd
228229
* @return {Promise<Blob>}
229230
*/
230-
async function sign1(pdf, cert, pwd, opwd){
231+
async function signAndProtect1(pdf, cert, pwd, opwd){
231232
/** @type {SignOption} */
232233
var sopt = {
233234
p12cert: cert,
@@ -245,14 +246,41 @@ async function sign1(pdf, cert, pwd, opwd){
245246
}
246247
```
247248

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+
248276
## Detail of EncryptOption
249277

250278
* __mode__: Zga.Crypto.Mode :point_right: The values of Zga.Crypto.Mode
251279
* RC4_40: 40bit RC4 Encryption
252280
* RC4_128: 128bit RC4 Encryption
253281
* AES_128: 128bit AES Encryption
254282
* 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
256284
* "copy": (Only valid on public-key mode) Copy text and graphics from the document;
257285
* "print": Print the document;
258286
* "modify": Modify the contents of the document by operations other than those controlled by 'fill-forms', 'extract' and 'assemble';

0 commit comments

Comments
 (0)