I have found:

They both rely on PDFTk, which costs around $1,000.

Where can I learn more about pdf compression with node, or find the already made library ?

0

3 Answers

Try using shrinkpdf to compress your pdf file

And this post: How to run shell script file using nodejs?

1

Using ghostscript4js:

gs.executeSync('gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=out.pdf in.pdf')

See this answer for various options.

Needs to have ghostscript installed on the host system though.

This can be easily achieved with ConvertAPI NodeJS library:

var convertapi = require('convertapi')('<YOUR SECRET HERE>'); convertapi.convert('compress', { File: '/path/to/my_file.pdf' }, 'pdf').then(function(result) { result.saveFiles('/path/to/dir'); }); 

The compression level can be adjusted by specifying the image compression algorithms and quality. You can also remove redundant objects from the PDF including fonts, bookmarks, annotations, forms, page labels, article threads, tagged information, page thumbnails, layers, duplicates, piece information dictionaries like Adobe Illustrator or Photoshop private data, etc.

You can find a complete list of compression parameters here: and the auto-generated code snippet at the bottom of the page.

Disclaimer: I work for the vendor of the library.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy