generated from victorsoares96/lib-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from victorsoares96/docs/update-readme
📝 docs: update readme
- Loading branch information
Showing
3 changed files
with
54 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,59 @@ | ||
# lib-template | ||
# compress-pdf | ||
|
||
## After all | ||
This library provides compress your PDFs using ghostscript | ||
|
||
Insert this secrets into your project repository. | ||
## Installation | ||
|
||
<https://docs.github.com/en/enterprise-cloud@latest/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-an-organization> | ||
Download ghostscript binaries available in releases page inside this repository. Example name: `gs_10.01.linux/windows.zip` or run: `npx compress-pdf --fetchBinaries [win32/linux]` to download binaries to inside **lib_folder/bin/gs** | ||
|
||
```json | ||
NPM_TOKEN= | ||
CODECOV_TOKEN= | ||
Then, extract and appoint: | ||
|
||
```sh | ||
npm install compress-pdf | ||
``` | ||
|
||
```sh | ||
yarn add compress-pdf | ||
``` | ||
|
||
### Code Usage | ||
|
||
```tsx | ||
import path from 'path'; | ||
import fs from 'fs'; | ||
import compressPdf from 'compress-pdf'; | ||
|
||
/** | ||
* After this run: | ||
* `npx compress-pdf --fetchBinaries [win32/linux]` | ||
* This will download properly binaries to your current os. | ||
*/ | ||
|
||
(async () => { | ||
const pdf = path.resolve(__dirname, 'A17_FlightPlan.pdf'); | ||
const buffer = await compressPdf(pdf); | ||
|
||
const compressedPdf = path.resolve(__dirname, 'compressed_pdf.pdf'); | ||
await fs.promises.writeFile(compressedPdf, buffer); | ||
})(); | ||
``` | ||
|
||
## CLI Usage | ||
|
||
``` | ||
npx compress-pdf --file [PDF_FILE] --output ./compressed.pdf | ||
Options: | ||
--file [PDF_FILE] (REQUIRED) | ||
--output [COMPRESSED_PDF_FILE] (REQUIRED) | ||
--resolution [ebook/printer/screen/prepress] | ||
--compatibilityLevel [NUMBER] The compatibility pdf level | ||
--binPath [DIRECTORY] The directory of ghostscript binaries. Default is lib_folder/bin/gs | ||
--fetchBinaries [win32/linux] Download binaries to default binaries path | ||
``` | ||
|
||
**You can see examples in [examples folder](https://github.com/victorsoares96/compress-pdf/tree/master/examples)** | ||
|
||
## License | ||
|
||
lib-template is licensed under the [MIT License](http://www.opensource.org/licenses/mit-license.php). | ||
This project is under MIT license, see [LICENSE.md](https://github.com/victorsoares96/compress-pdf/blob/master/LICENSE) for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters