【发布时间】:2017-09-29 09:39:18
【问题描述】:
【问题讨论】:
标签: node.js pdf compression
【问题讨论】:
标签: node.js pdf compression
尝试使用shrinkpdf 压缩您的pdf文件
【讨论】:
使用ghostscript4js:
gs.executeSync('gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=out.pdf in.pdf')
请参阅this answer 了解各种选项。
需要在主机系统上安装 ghostscript。
【讨论】:
这可以通过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');
});
可以通过指定image compression algorithms 和质量来调整压缩级别。您还可以从 PDF 中remove redundant objects 包括字体、书签、注释、表单、页面标签、文章线程、标记信息、页面缩略图、图层、副本、Adobe Illustrator 或 Photoshop 私人数据等片段信息字典等。
您可以在此处找到完整的压缩参数列表:https://www.convertapi.com/pdf-to-compress 和bottom of the page 上的自动生成代码 sn-p。
免责声明:我为图书馆的供应商工作。
【讨论】: