Skip to content

Commit

Permalink
Merge pull request #71 from victorsoares96/fix/compress-protected-pdf…
Browse files Browse the repository at this point in the history
…-by-cli

🩹 fix: compress protected pdf by cli
  • Loading branch information
victorsoares96 committed Jan 25, 2024
2 parents bc6904d + 2b5dc2e commit 046aea7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 5 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ type CliOptions = {
'--resolution'?: Resolution;
'--compatibilityLevel'?: string;
'--gsModule'?: string;
'--pdfPassword'?: string;
'--removePasswordAfterCompression'?: boolean;
};

(async () => {
Expand All @@ -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'
);
}

Expand All @@ -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);
Expand Down

0 comments on commit 046aea7

Please sign in to comment.