Skip to main content

borb is a library for reading, creating and manipulating PDF files in python.

Project description

borb logo borb

Code style: black Corpus Coverage : 100.0% Text Extraction : 93.1% Public Method Documentation : 100% Number of Tests : 414 Python : 3.8 | 3.9 | 3.10

Downloads Downloads

borb is a library for creating and manipulating PDF files in python.

0. About borb

borb is a pure python library to read, write and manipulate PDF documents. It represents a PDF document as a JSON-like datastructure of nested lists, dictionaries and primitives (numbers, string, booleans, etc)

This is currently a one-man project, so the focus will always be to support those use-cases that are more common in favor of those that are rare.

1. About the Examples

The examples can be found in a separate repository. This ensures the borb repository stays relatively small, whilst still providing a thorough knowledgebase of code-samples, screenshots and explanatory text.

Check out the examples repository here!

They include;

  • Reading a PDF and extracting meta-information
  • Changing meta-information
  • Extracting text from a PDF
  • Extracting images from a PDF
  • Changing images in a PDF
  • Adding annotations (notes, links, etc) to a PDF
  • Adding text to a PDF
  • Adding tables to a PDF
  • Adding lists to a PDF
  • Using a PageLayout manager

and much more

1.0 Installing borb

borb can be installed using pip

pip install borb

If you have installed borb before, and you want to ensure pip downloads the latest version (rather than using its internal cache) you can use the following commands:

pip uninstall borb
pip install --no-cache borb

1.1 Hello World

To give you an immediate idea of the way borb works, this is the classic Hello World example, in borb:

from pathlib import Path

from borb.pdf import Document
from borb.pdf import Page
from borb.pdf import SingleColumnLayout
from borb.pdf import Paragraph
from borb.pdf import PDF

# create an empty Document
pdf = Document()

# add an empty Page
page = Page()
pdf.add_page(page)

# use a PageLayout (SingleColumnLayout in this case)
layout = SingleColumnLayout(page)

# add a Paragraph object
layout.add(Paragraph("Hello World!"))
    
# store the PDF
with open(Path("output.pdf"), "wb") as pdf_file_handle:
    PDF.dumps(pdf_file_handle, pdf)

2. License

borb is dual licensed as AGPL/Commercial software.

AGPL is a free / open source software license. This doesn't mean the software is gratis!

Buying a license is mandatory as soon as you develop commercial activities distributing the borb software inside your product or deploying it on a network without disclosing the source code of your own applications under the AGPL license. These activities include:

  • Offering paid services to customers as an ASP
  • Serving PDFs on the fly in the cloud or in a web application
  • Shipping borb with a closed source product

Contact sales for more information.

3. Acknowledgements

I would like to thank the following people, for their contributions / advice with regards to developing borb:

  • Aleksander Banasik
  • Benoît Lagae
  • Michael Klink

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

borb-2.1.5.4.tar.gz (8.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

borb-2.1.5.4-py3-none-any.whl (8.7 MB view details)

Uploaded Python 3

File details

Details for the file borb-2.1.5.4.tar.gz.

File metadata

  • Download URL: borb-2.1.5.4.tar.gz
  • Upload date:
  • Size: 8.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for borb-2.1.5.4.tar.gz
Algorithm Hash digest
SHA256 188258ec1362b9df99af0bcf8a2dec0c34318854921f45bd7affaf5a41050b61
MD5 4f9476713586a33dc8519f4a157c9f24
BLAKE2b-256 7499e07c338a4e700a260f7858d2c0feb39b94d9eb48b7eda37a7fddb0dadc31

See more details on using hashes here.

File details

Details for the file borb-2.1.5.4-py3-none-any.whl.

File metadata

  • Download URL: borb-2.1.5.4-py3-none-any.whl
  • Upload date:
  • Size: 8.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for borb-2.1.5.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9d2ba045e811e0f71fb40d79bd340454773fafecbc30a4045aa26b8715adbde4
MD5 9007937b479e1daa8d2b5950b0bdfe4c
BLAKE2b-256 1b34cf6c7162307668d5a8836064759622c4b40dad5149c55c4a6fe9814fafc8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page