Skip to content

BUG TextField objects are not editable when added to an existing PDF #138

@stimon

Description

@stimon

Describe the bug
TextField objects that are added to existing PDF pages with absolute positioning are displayed, but not editable.

To Reproduce

  1. Open an existing PDF.
  2. Iterate the document pages and add TextField objects to a specific position with paint method.
  3. Save document as a new PDF
from borb.pdf import Document
from borb.pdf import PDF
from borb.pdf.canvas.geometry.rectangle import Rectangle
from decimal import Decimal
from borb.pdf import Page
from borb.pdf import Paragraph
from borb.pdf import TextField

with open("questionnaire.pdf", "rb") as in_file_handle:
    doc = PDF.loads(in_file_handle)

info = doc.get_document_info()
N = int(info.get_number_of_pages())
r: Rectangle = Rectangle(
        Decimal(50),
        Decimal(5),
        Decimal(100),
        Decimal(5),
    )
subfield = TextField(field_name="subject_id")
for i in range(0, N):
    page = doc.get_page(i)
    subfield.paint(page, r)
    

with open("borbtest.pdf", "wb") as pdf_out_handle:
    PDF.dumps(pdf_out_handle, doc)

Expected behaviour
The TextField object should be editable in the output PDF.
The aim is that entering text in any of the pages updates all text fields. That is why I'm using one TextField object for all pages. I'm unsure if this is the right approach or possible at all.

Screenshots
screenshot

Desktop (please complete the following information):

  • OS: Mac OSX 12.6
  • borb version: 2.1.5.2
  • The input PDF is a Clinical Research Form and should not be shared because it includes licensed clinical tests.

Additional context
The aim is to add an input text field to enter the subject ID and carry it over all pages before printing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions