用python读写pdf,qpdf支持
pikepdf的Python项目详细描述
pikepdf
pikepdf是一个用于读取和写入pdf文件的python库。
pikepdf基于QPDF,一个强大的pdf操作和修复库。
Python +QPDF=“Py”+“qPDF”=“PYQPDF”,看起来像诵读困难测试。大声说出来,听起来像“pikepdf”。
# Elegant, Pythonic APIwithpikepdf.open('input.pdf')aspdf:num_pages=len(pdf.pages)delpdf.pages[-1]pdf.save('output.pdf')
要安装:
完全支持Python3.5、3.6和3.7。
pip install pikepdf
对于希望从源代码生成的用户,请参见installation。
pikepdf是documented并积极维护的。提供商业支持。
功能
此库类似于PyPDF2和PDFRW,它提供了对PDF特征的低级别访问,并允许对现有PDF进行编辑和内容转换。对pdf规范的一些知识可能会有所帮助。它无法将pdf呈现为图像。
Feature | pikepdf | PyPDF2 | pdfrw |
---|---|---|---|
Editing, manipulation and transformation of existing PDFs | ✔ | ✔ | ✔ |
Based on an existing, mature PDF library | QPDF | ✘ | ✘ |
Implementation | C++ and Python | Python | Python |
PDF versions supported | 1.1 to 1.7 | 1.3? | 1.7 |
Python versions supported | 3.5-3.7 | 2.6-3.6 | 2.6-3.6 |
Save and load password protected (encrypted) PDFs | ✔ (except public key) | ✘ (Only obsolete RC4) | ✘ (not at all) |
Save and load PDF compressed object streams (PDF 1.5) | ✔ | ✘ | ✘ |
Creates linearized ("fast web view") PDFs | ✔ | ✘ | ✘ |
Actively maintained | |||
Test suite coverage | ~86% | very low | unknown |
Creates PDFs that pass PDF validation tests | ✔ | ✘ | ? |
Modifies PDF/A without breaking PDF/A compliance | ✔ | ✘ | ? |
Automatically repairs PDFs with internal errors | ✔ | ✘ | ✘ |
PDF XMP metadata editing | ✔ | read-only | ✘ |
Documentation | ✔ | ✘ | ✔ |
Integrates with Jupyter and IPython notebooks for rapid development | ✔ | ✘ | ✘ |
生产中
- {A7}使用PIKEPDF将OCR文本层移植到现有的PDF文件中,检查输入PDF的内容,并优化PDFS。
许可证
pikepdf是在Mozilla Public License 2.0许可证(mpl)下提供的,可以在许可证文件中找到。通过使用、分发或参与此项目,您同意本许可的条款和条件。
Informally,mpl 2.0不是“病毒”许可证。它可以与其他工作相结合,包括商业软件。但是,您必须以源代码形式将修改公开到pikepdf。在其他工作中,在github或其他地方派生这个存储库并在那里提交您的贡献,您就完成了您的义务。mpl 2.0与gpl和lgpl兼容-有关在gpl中使用的说明,请参见guidelines。
tests/resources/copyright
文件描述了测试套件的许可条款和测试资源的来源。