{"id":5136,"library":"borb","title":"borb PDF Library","description":"borb is a comprehensive Python library designed for reading, creating, and manipulating PDF files. It offers a wide range of functionalities from simple text and image handling to advanced layout management. The library is actively maintained with frequent patch releases, typically on a monthly or bi-monthly cadence, adding new features and improving robustness.","status":"active","version":"3.0.7","language":"en","source_language":"en","source_url":"https://github.com/borb-pdf/borb","tags":["pdf","document processing","pdf generation","pdf manipulation","document automation"],"install":[{"cmd":"pip install borb","lang":"bash","label":"Core library"},{"cmd":"pip install borb[full]","lang":"bash","label":"With all optional features (images, text processing, AI)"},{"cmd":"pip install borb[image,text,genai]","lang":"bash","label":"Specific optional features"}],"dependencies":[{"reason":"Required for image processing features, included with `[image]` or `[full]` extras.","package":"Pillow","optional":true},{"reason":"Used for geometric operations, often part of text or layout processing, included with `[text]` or `[full]` extras.","package":"shapely","optional":true},{"reason":"For generative AI features, included with `[genai]` or `[full]` extras.","package":"transformers","optional":true}],"imports":[{"symbol":"Document","correct":"from borb.pdf.document.document import Document"},{"symbol":"Page","correct":"from borb.pdf.page.page import Page"},{"symbol":"Paragraph","correct":"from borb.pdf.canvas.layout.text.paragraph import Paragraph"},{"symbol":"Image","correct":"from borb.pdf.canvas.layout.image.image import Image"},{"symbol":"PDF","correct":"from borb.pdf.pdf import PDF"},{"symbol":"Rectangle","correct":"from borb.pdf.canvas.geometry.rectangle import Rectangle"}],"quickstart":{"code":"from borb.pdf.document.document import Document\nfrom borb.pdf.page.page import Page\nfrom borb.pdf.canvas.layout.text.paragraph import Paragraph\nfrom borb.pdf.pdf import PDF\nfrom borb.pdf.canvas.geometry.rectangle import Rectangle\nimport os\n\ndef create_hello_world_pdf():\n    # Create a new Document\n    pdf = Document()\n    # Add a Page\n    page = Page()\n    pdf.add_page(page)\n\n    # Add a Paragraph with 'Hello World!'\n    page.add_layout_element(\n        Paragraph(\n            \"Hello World! This is a borb generated PDF.\",\n            bounding_box=Rectangle(50, 700, 500, 50)\n        )\n    )\n\n    # Define output path\n    output_path = os.environ.get('BORB_OUTPUT_PATH', 'hello_borb.pdf')\n\n    # Store the PDF to a file\n    with open(output_path, \"wb\") as pdf_file_handle:\n        PDF.add_document_to_file(pdf, pdf_file_handle)\n    print(f\"PDF saved to {output_path}\")\n\nif __name__ == \"__main__\":\n    create_hello_world_pdf()","lang":"python","description":"This quickstart demonstrates how to create a simple PDF document containing 'Hello World!' text using borb. It initializes a Document, adds a Page, places a Paragraph using a bounding box, and saves the document to a file."},"warnings":[{"fix":"Review the borb v3.x documentation and examples, particularly regarding numeric handling and the new `LayoutElement` paradigm for annotations and other page content.","message":"Major architectural changes in borb v3.0.0/v3.0.1, including the removal of the `Decimal` type for numeric operations and the integration of `Annotation` objects into the `LayoutElement` framework. Code written for borb v2.x will likely require significant modification.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Install borb with the `[full]` extra (`pip install borb[full]`) or specify the required feature groups (e.g., `pip install borb[image,text]`) to ensure all necessary dependencies are met for your use case.","message":"Starting with v3.0.7, many advanced features (e.g., image processing, advanced text layout, generative AI integrations) are moved to optional 'extras'. A simple `pip install borb` will only install the core library. To access full functionality, you must install with `borb[full]` or specific feature groups like `borb[image,text]`.","severity":"gotcha","affected_versions":">=3.0.7"},{"fix":"Upgrade to borb v3.0.1 or newer. If forced to use an older version, consult borb's GitHub issues for potential workarounds for packaging non-Python assets.","message":"Versions prior to v3.0.1 had packaging issues due to the inclusion of non-Python files, which could cause problems when attempting to package or deploy `borb` in certain environments.","severity":"gotcha","affected_versions":"<3.0.1"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}