采用 AGPL 与商业双许可,闭源项目或对外提供付费 PDF 服务需购买商业授权;README 未说明 Python 版本以外的系统依赖

borb
borb-pdf活跃维护纯 Python 的 PDF 库,能读取、生成和修改 PDF 文件,还内置排版能力,适合在代码里直接拼装报表、发票等文档。
borb is a library for reading, creating and manipulating PDF files in python.
纯 Python 的 PDF 读写与操作库,用类似 JSON 的嵌套结构建模文档,适合常规 PDF 处理场景
纯 Python 的 PDF 库,能读取、生成和修改 PDF 文件,还内置排版能力,适合在代码里直接拼装报表、发票等文档。
核心能力
- 用嵌套列表、字典和基本类型建模 PDF 结构
- 支持读取、编辑 PDF 元数据
- 支持提取文本与图片
- 支持添加注释(便签、链接)
- 用 PageLayout 管理页面布局并添加文本、图片、表格、列表
容易踩的坑
- v3.0.9最新正式版2026-08-03 · 2026-08-03 21:08 UTC
📣 borb v3.0.9
Improvements & Maintenance:
- Improved visual regression testing: A comprehensive visual validation workflow was introduced, including visual assertions, reference ground-truth assets, and additional visual checks. These enhancements provide stronger guarantees that rendering changes do not introduce unintended regressions.
- Fixed border rendering issues: Several rendering bugs related to borders were resolved, improving layout accuracy and ensuring more consistent document appearance across different rendering scenarios.
- Improved layout calculations: A typo affecting padding calculations for layout chunks was corrected, resulting in more reliable spacing and alignment behavior.
- Enhanced test infrastructure: The smoke test suite was modernized by removing its dependency on Pillow (PIL), simplifying the testing environment while improving maintainability and portability.
- Static typing improvements: Additional mypy warnings were resolved across the codebase, strengthening type safety and reducing the likelihood of subtle runtime issues.
- General bug fixes and stability improvements: Multiple smaller fixes and refinements were applied throughout the library, increasing overall robustness and reliability.
- CI/CD workflow improvements: The package build workflow now supports manual (
workflow_dispatch) execution, providing greater flexibility for release management and maintenance tasks. - Dependency maintenance: GitHub Actions dependencies were updated, including an upgrade of
actions/checkout, keeping the development and release infrastructure current.
Internal Maintenance:
- Expanded visual regression infrastructure for long-term rendering stability.
- Continued cleanup of testing utilities and supporting infrastructure.
- Ongoing improvements to static analysis and code quality.
- Routine dependency and continuous integration maintenance.
These release notes were AI-generated from the public changelog and commit summaries, and while care was taken to reflect them accurately, they may still contain omissions or small inaccuracies.
- v3.0.82026-06-14 · 2026-06-14 19:17 UTC
查看更新说明
📣 borb v3.0.8
Improvements & Maintenance:
- Expanded rounded border system across layout elements: Rounded corner support was significantly extended across multiple LayoutElement implementations, improving visual consistency and giving developers finer control over rendered UI components.
- Improved testing for rounded border rendering: New tests were added for images with rounded borders, strengthening coverage and ensuring correct rendering behavior across edge cases.
- Refinements to layout internals: Several iterations of improvements to rounded border handling were introduced, stabilizing behavior across different layout components and consolidating earlier incremental changes.
- LayoutElement robustness improvements: Method ordering and internal structure adjustments were applied to improve maintainability and reduce subtle integration issues in complex layouts.
- Code quality and type safety improvements: Multiple mypy fixes and static typing refinements were introduced across core modules, improving long-term reliability and reducing type-related regressions.
- Formatting and linting cleanup: Black formatting fixes were applied, including cleanup in self_truncating_heterogeneous_paragraph, keeping the codebase consistent with formatting standards.
- Test and rendering stability improvements: Additional subsetting tests and minor rendering-related fixes further improved robustness of document generation workflows.
- Rendering fallback and font handling improvements (maintenance work): Internal refactoring in font-related components and screenshot fallback behavior improved resilience in edge cases.
Internal Maintenance:
- Ongoing incremental refactoring of rendering and layout internals
- Continuous cleanup of legacy formatting inconsistencies
- Gradual consolidation of layout rendering behavior for future extensibility
These release notes were AI-generated from the public changelog and commit summaries, and while care was taken to reflect them accurately, they may still contain omissions or small inaccuracies.
- v3.0.72026-03-16 · 2026-03-16 21:49 UTC
查看更新说明
📣 borb v3.0.7
Improvements & Maintenance:
- Improved dependency management: The packaging configuration was refined to better support optional functionality. Feature groups such as
image,text, andgenaiare now exposed as installable extras, making it easier to install only the components required for a given workflow. - Convenient full installation option: A new
fullextra installs the union of all runtime feature dependencies, providing a simple way to enable the complete borb feature set. - Enhanced package metadata: Additional metadata such as improved keywords and packaging structure was added to improve discoverability and clarity on package indexes.
- Automated dependency updates: Added automated dependency monitoring and update proposals via
Dependabot, helping keep development tooling and integrations up to date with minimal maintenance overhead. - Packaging cleanup: Minor refactoring of the packaging configuration improves maintainability and keeps the project aligned with modern Python packaging practices.
These release notes were AI-generated from the public changelog and commit summaries, and while care was taken to reflect them accurately, they may still contain omissions or small inaccuracies.
- Improved dependency management: The packaging configuration was refined to better support optional functionality. Feature groups such as
- v3.0.62026-02-23 · 2026-02-23 19:05 UTC
查看更新说明
📣 borb v3.0.6
Improvements & Maintenance:
- Extended add-on ecosystem support: Built on the previously introduced template repository for borb add-ons, paving the way for a more modular extension ecosystem and smoother community-driven tooling.
- Graphics and color handling refinements: Minor but impactful fixes were integrated that improve the robustness of PDF rendering paths, particularly where very small or edge-case content streams had previously triggered assertion failures.
- Optional dependencies hardened: Usage statistics collection is now fully optional, with import guards preventing failures when optional packages like requests are absent.
- Code formatting and consistency: Continued alignment with current Python tooling — including updated black formatting standards — ensures consistent style and reduced diff churn across commits.
- GitHub workflow and CI enhancements: Alignment to add-on templates carried through to workflows, improving automated checks and streamlining development pipelines.
Bug Fixes:
- Improved PDF resilience: Fixed an issue where extremely small PDF files could lead to assertive failures during parsing.
- Safer imports: Avoids broken imports when optional packages are not installed by guarding around those modules.
These release notes were AI-generated from the public changelog and commit summaries, and while care was taken to reflect them accurately, they may still contain omissions or small inaccuracies.
- v3.0.52026-01-24 · 2026-01-24 09:45 UTC
查看更新说明
📣 borb v3.0.5
Improvements & Maintenance:
- Introduced a template repository for
borbadd-ons, improving consistency and maintainability across extensions. - Aligned the main
borbrepository more closely with the add-on template, including updates toGitHubworkflows. - Updated code formatting to a newer version of
black, ensuring consistent formatting going forward. - Fixed a bug where very small PDFs could trigger an assertion error during processing.
- Made usage statistics truly optional by guarding the requests import with a
try/except, avoiding failures when the dependency is not installed.
These release notes were AI-generated based on a provided list of changes, and while care was taken to reflect them accurately, they may still contain errors or omissions.
- Introduced a template repository for
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
borb
borb is a powerful and flexible Python library for creating and manipulating PDF files.
📖 Overview
borb provides a pure Python solution for PDF document management, allowing users to read, write, and manipulate PDFs. It models PDF files in a JSON-like structure, using nested lists, dictionaries, and primitives (numbers, strings, booleans, etc.). Created and maintained as a solo project, borb prioritizes common PDF use cases for practical and straightforward usage.
✨ Features
Explore borb’s capabilities in the examples repository for practical, real-world applications, including:
- PDF Metadata Management (reading, editing)
- Text and Image Extraction
- Adding Annotations (notes, links)
- Content Manipulation (adding text, images, tables, lists)
- Page Layout Management with
PageLayout
…and much more!
🚀 Installation
Install borb directly via pip:
pip install borb
To ensure you have the latest version, consider the following commands:
pip uninstall borb
pip install --no-cache borb
👋 Getting Started: Hello World
Create your first PDF in just a few lines of code with borb:
from pathlib import Path
from borb.pdf import Document, Page, PageLayout, SingleColumnLayout, Paragraph, PDF
# Create an empty Document
d: Document = Document()
# Create an empty Page
p: Page = Page()
d.append_page(p)
# Create a PageLayout
l: PageLayout = SingleColumnLayout(p)
# Add a Paragraph
l.append_layout_element(Paragraph('Hello World!'))
# Write the PDF
PDF.write(what=d, where_to="assets/output.pdf")
🛠 License
borb is dual-licensed under AGPL and a commercial license.
The AGPL (Affero General Public License) is an open-source license, but commercial use cases require a paid license, especially if you intend to:
- Offer paid PDF services (e.g., PDF generation in cloud applications)
- Use
borbin closed-source projects - Distribute
borbin any closed-source product
For more information, contact our sales team.
🙏 Acknowledgements
Special thanks to:
- Aleksander Banasik
- Benoît Lagae
- Michael Klink
Your contributions and guidance have been invaluable to borb's development.