From 24628c6a367ba46edd05b372c98127bf8f283eef Mon Sep 17 00:00:00 2001 From: Victor Soares Date: Thu, 25 Jan 2024 13:52:37 -0300 Subject: [PATCH 1/2] :adhesive_bandage: fix: compress protected pdf by cli --- package.json | 2 +- src/cli.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3ea233f..80bbb64 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "compress-pdf", - "version": "0.5.0", + "version": "0.5.1", "templateVersion": "1.3.0", "description": "An compress pdf library using ghostscript", "main": "dist/index.js", diff --git a/src/cli.ts b/src/cli.ts index c0d127e..79c1530 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -9,6 +9,8 @@ type CliOptions = { '--resolution'?: Resolution; '--compatibilityLevel'?: string; '--gsModule'?: string; + '--pdfPassword'?: string; + '--removePasswordAfterCompression'?: boolean; }; (async () => { @@ -33,7 +35,7 @@ type CliOptions = { process.argv.slice(2).length === 0 ) { return console.log( - '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' + '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' ); } @@ -49,6 +51,8 @@ type CliOptions = { ? Number(args['--compatibilityLevel']) : undefined, gsModule: args['--gsModule'], + pdfPassword: args['--pdfPassword'], + removePasswordAfterCompression: args['--removePasswordAfterCompression'], }); return fs.writeFileSync(args['--output'], buffer); From 2b5dc2e091221c5884a013ebbbe84ab0bdc368ed Mon Sep 17 00:00:00 2001 From: Victor Soares Date: Thu, 25 Jan 2024 13:54:29 -0300 Subject: [PATCH 2/2] :memo: docs: update readme --- README.md | 2 ++ src/cli.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1c22b52..634c776 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,8 @@ Options: --resolution [ebook/printer/screen/prepress] --compatibilityLevel [NUMBER] The compatibility pdf level --gsModule [FILE PATH] The directory of ghostscript binaries. Ex: /usr/bin/gs + --pdfPassword The pdf password + --removePasswordAfterCompression [BOOLEAN] Remove pdf password after compression ``` ### Usage with Docker diff --git a/src/cli.ts b/src/cli.ts index 79c1530..5fae01b 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -35,7 +35,7 @@ type CliOptions = { process.argv.slice(2).length === 0 ) { return console.log( - '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' + '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' ); }