I've installed the borb library using pip and I'm getting an error in the below block
from borb.pdf import Document
from borb.pdf.page.page import Page
# Create document
pdf = Document()
# Add page
page = Page()
pdf.append_page(page)
In the above code I'm getting the error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-4-f883c75f0cd9> in <cell line: 9>()
7 # Add page
8 page = Page()
----> 9 pdf.append_page(page)
AttributeError: 'Document' object has no attribute 'append_page'
How can I solve this?
The error is self-explanatory; the
documentdoes not have any function to append the page. This may be due to the fact that (1) the actual function does not have have that attribute, (2) or you are typing it incorrectly.In your case, I think it is a typo:
instead of
append_page(); it should beadd_page().https://github.com/jorisschellekens/borb
Plus, from the above link, it seems that your 2nd import is incorrect; it should be:
from borb.pdf import Page