Skip to content

Commit 046aea7

Browse files
Merge pull request #71 from victorsoares96/fix/compress-protected-pdf-by-cli
🩹 fix: compress protected pdf by cli
2 parents bc6904d + 2b5dc2e commit 046aea7

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ Options:
6464
--resolution [ebook/printer/screen/prepress]
6565
--compatibilityLevel [NUMBER] The compatibility pdf level
6666
--gsModule [FILE PATH] The directory of ghostscript binaries. Ex: /usr/bin/gs
67+
--pdfPassword The pdf password
68+
--removePasswordAfterCompression [BOOLEAN] Remove pdf password after compression
6769
```
6870

6971
### Usage with Docker

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "compress-pdf",
3-
"version": "0.5.0",
3+
"version": "0.5.1",
44
"templateVersion": "1.3.0",
55
"description": "An compress pdf library using ghostscript",
66
"main": "dist/index.js",

src/cli.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ type CliOptions = {
99
'--resolution'?: Resolution;
1010
'--compatibilityLevel'?: string;
1111
'--gsModule'?: string;
12+
'--pdfPassword'?: string;
13+
'--removePasswordAfterCompression'?: boolean;
1214
};
1315

1416
(async () => {
@@ -33,7 +35,7 @@ type CliOptions = {
3335
process.argv.slice(2).length === 0
3436
) {
3537
return console.log(
36-
'USE: npx compress-pdf\n--file [PDF_FILE]\n--output [COMPRESSED_PDF_FILE]\n--resolution [ebook/printer/screen/prepress]\n--compatibilityLevel [NUMBER] The compatibility pdf level\n--gsModule [FILE PATH] The ghostscript binary path. Ex: /usr/local/bin/gs'
38+
'USE: npx compress-pdf\n--file [PDF_FILE]\n--output [COMPRESSED_PDF_FILE]\n--resolution [ebook/printer/screen/prepress]\n--compatibilityLevel [NUMBER] The compatibility pdf level\n--gsModule [FILE PATH] The ghostscript binary path\n--pdfPassword The pdf password\n--removePasswordAfterCompression [BOOLEAN] Remove pdf password after compression\nEx: /usr/local/bin/gs'
3739
);
3840
}
3941

@@ -49,6 +51,8 @@ type CliOptions = {
4951
? Number(args['--compatibilityLevel'])
5052
: undefined,
5153
gsModule: args['--gsModule'],
54+
pdfPassword: args['--pdfPassword'],
55+
removePasswordAfterCompression: args['--removePasswordAfterCompression'],
5256
});
5357

5458
return fs.writeFileSync(args['--output'], buffer);

0 commit comments

Comments
 (0)