Package Exports
- compress-pdf
- compress-pdf/dist/index.js
- compress-pdf/dist/index.mjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (compress-pdf) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
compress-pdf
This library provides compress your PDFs using ghostscript
Installation
npm install compress-pdfyarn add compress-pdfCode Usage
import path from 'path';
import fs from 'fs';
import { compress } from 'compress-pdf';
(async () => {
const pdf = path.resolve(__dirname, 'A17_FlightPlan.pdf');
const buffer = await compress(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 pathYou can see examples in examples folder
License
This project is under MIT license, see LICENSE.md for details.