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 ?
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.
Try using shrinkpdf to compress your pdf file
And this post: How to run shell script file using nodejs?
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: https://www.convertapi.com/pdf-to-compress and the auto-generated code snippet at the bottom of the page.
Disclaimer: I work for the vendor of the library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With