django 有没有办法通过python高度压缩PDF文件?

fcy6dtqo  于 2023-04-07  发布在  Go
关注(0)|答案(1)|浏览(120)

我已经通过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:

  1. PDFNetPython 3 python包-需要许可证/密钥文件。
  2. Ghost-script命令从系统(ubuntu)终端减少文件。
  3. shrinkpdf.sh -文件来自github。
  4. ps2 pdf命令从系统终端。
  5. pdfsizeopt
  6. 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.
3qpi33ja

3qpi33ja1#

压缩选项中的图像:
pdfkit.from_url('http://google.com', 'out.pdf', options={"image-quality": 30, "lowquality": True})
你可以在这里看到你可以传递的其他选项:
https://wkhtmltopdf.org/usage/wkhtmltopdf.txt
祝你好运!

相关问题