pythonpdfborb

ImportError when attempting to create a header using borb PDF library in Python


I'm trying to create a header in a PDF document using the borb library in Python. However, I'm encountering an ImportError when attempting to import the necessary modules. Here's my code:

from borb.pdf import Page
from borb.pdf import Document
from borb.pdf import MultiColumnLayout
from borb.pdf import PageLayout
from borb.pdf.canvas.layout.layout_element import Container, Span

# Further code to create header and add content

The error message I'm getting is:

ImportError: cannot import name 'Container' from 'borb.pdf.canvas.layout.layout_element'

I've tried various import statements, but I can't seem to get past this error. Can someone help me understand what I'm doing wrong and how I can correctly import these modules to create a header in my PDF document using borb?


Solution

  • disclaimer: I am the author of the borb library

    chatGPT is not always able to generate working code. In this case, it invented a class Container, which does not exist in borb.

    Depending on what you want to do precisely, you should check out the other implementations of LayoutElement.