我已经通过python使用django服务器上运行的pdfkit库生成了一个PDF文件。The size of pdf generated is 43.2 MB.
Total pages in pdf = 15.
Each page has 70 images, each image size = 623 bytes.
Tech Stack version used-
-Python = 3.8.16
-pdfkit = 1.0.0
-wkhtmltopdf = 0.12.6
-Django = 3.2.16
系统操作系统= Ubuntu 22.04.2 LTS
要求是压缩此PDF文件,而不影响内容的质量,其中的图像。
Any approach or suggestions for improvements in the things tried?
Things tried:
- PDFNetPython 3 python包-需要许可证/密钥文件。
- Ghost-script命令从系统(ubuntu)终端减少文件。
- shrinkpdf.sh -文件来自github。
- ps2 pdf命令从系统终端。
- pdfsizeopt
- CPDF
1.制作原始文件的zip
1.在pdfkit选项中更改dpi值。File size after compression with quality of content maintained = 23.7 MB.
Expectation is have more reduction in file size.
1条答案
按热度按时间3qpi33ja1#
压缩选项中的图像:
pdfkit.from_url('http://google.com', 'out.pdf', options={"image-quality": 30, "lowquality": True})
你可以在这里看到你可以传递的其他选项:
https://wkhtmltopdf.org/usage/wkhtmltopdf.txt
祝你好运!