From e87029c8376e564fd24396abe059eda0a9b22064 Mon Sep 17 00:00:00 2001 From: Joe Barrow Date: Sat, 18 Oct 2025 20:35:13 -0400 Subject: [PATCH 1/4] test 3.9+3.10 --- .github/workflows/ci.yml | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f300e48..6a716f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.11", "3.12", "3.13"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] steps: - name: Checkout diff --git a/pyproject.toml b/pyproject.toml index a4e46ec..e6094c2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "commonforms" version = "0.1.5" description = "Automatically convert a PDF into a fillable form" readme = "README.md" -requires-python = ">=3.11" +requires-python = ">=3.9" urls = { Homepage = "https://github.com/jbarrow/commonforms" } dependencies = [ "cryptography>=3.1", From 02569ce38513251136874c699972f56c42f24eae Mon Sep 17 00:00:00 2001 From: Joe Barrow Date: Sun, 19 Oct 2025 12:51:11 -0400 Subject: [PATCH 2/4] update formalpdf==0.1.6 for python 3.9/3.10 support --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e6094c2..c54cb81 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ requires-python = ">=3.9" urls = { Homepage = "https://github.com/jbarrow/commonforms" } dependencies = [ "cryptography>=3.1", - "formalpdf==0.1.5", + "formalpdf==0.1.6", "huggingface-hub>=0.35.3", "onnx>=1.19.1", "onnxruntime>=1.23.1", From 39f6818b28eb1ea7e73b4a9931e0adaaad93d6d5 Mon Sep 17 00:00:00 2001 From: Joe Barrow Date: Sun, 19 Oct 2025 12:54:00 -0400 Subject: [PATCH 3/4] drop 3.9 support to align with onnx --- .github/workflows/ci.yml | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a716f9..f83175f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: ["3.10", "3.11", "3.12", "3.13"] steps: - name: Checkout diff --git a/pyproject.toml b/pyproject.toml index c54cb81..d60490c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "commonforms" version = "0.1.5" description = "Automatically convert a PDF into a fillable form" readme = "README.md" -requires-python = ">=3.9" +requires-python = ">=3.10" urls = { Homepage = "https://github.com/jbarrow/commonforms" } dependencies = [ "cryptography>=3.1", From 3e7f6ec6d809e7c7998fa7fdaebe6a38bc5b0648 Mon Sep 17 00:00:00 2001 From: opcan <62741296+opcan@users.noreply.github.com> Date: Sun, 19 Oct 2025 14:36:52 +0200 Subject: [PATCH 4/4] Create multiline_tools.py Add utility to enable multiline text fields in fillable PDFs --- commonforms/multiline_tools.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 commonforms/multiline_tools.py diff --git a/commonforms/multiline_tools.py b/commonforms/multiline_tools.py new file mode 100644 index 0000000..37b2944 --- /dev/null +++ b/commonforms/multiline_tools.py @@ -0,0 +1,24 @@ +from pypdf import PdfReader, PdfWriter +from pypdf.generic import NameObject, NumberObject + +def enable_multiline_fields(input_pdf: str, output_pdf: str): + """ + Enables multiline text input on all text fields in a fillable PDF. + """ + reader = PdfReader(input_pdf) + writer = PdfWriter() + + for page in reader.pages: + if "/Annots" in page: + for annot in page["/Annots"]: + obj = annot.get_object() + if obj.get("/FT") == NameObject("/Tx"): + current_flags = obj.get("/Ff", NumberObject(0)) + new_flags = int(current_flags) | 4096 # set multiline flag + obj.update({NameObject("/Ff"): NumberObject(new_flags)}) + writer.add_page(page) + + with open(output_pdf, "wb") as f: + writer.write(f) + + print(f"Done! Modified PDF saved as {output_pdf}") \ No newline at end of file