Forums

module pdfforms not working

hi there. i have a little python script that utilizes the pdfforms module but somehow I get an error. I installed it by typing

pip3.7 install --user pdfforms

I get the following error when I run pdfforms in bash console.

pdfforms
Traceback (most recent call last):
  File "/home/fishcakedev/.local/bin/pdfforms", line 11, in <module>
    sys.exit(main())
  File "/home/fishcakedev/.local/lib/python3.7/site-packages/pdfforms/pdfforms.py", line 167, in main
    args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

script works fine on my computer though

I'm a bit confused -- you installed the package using pip3.6, but from the traceback it looks like you're running Python 3.7. What happens if you try to import it using Python 3.6?

that was a typo. I have used pip3.7 of course. I get the same error in a python 3.7 venv

Hmm, it looks like there's a bug in Python's argparse library which means that when you run a command that expects command-line arguments -- that is, instead of running

pdfforms somecommand

...you just run

pdfforms

...then you get that error instead of a more user-friendly message saying something like "please specify a command".

What happens if you run a full command, like

pdfforms inspect f1040*.pdf

...?

that's the output for a full command

(myvenv) 18:14 ~/pdf $ pdfforms inspect arbeitszeit.pdf 
    Couldn't read /proc/self/stat
    Traceback (most recent call last):
      File "/home/fishcakedev/.virtualenvs/myvenv/bin/pdfforms", line 8, in <module>
        sys.exit(main())
      File "/home/fishcakedev/.virtualenvs/myvenv/lib/python3.7/site-packages/pdfforms/pdfforms.py", line 167, in main
        args.func(args)
      File "/home/fishcakedev/.virtualenvs/myvenv/lib/python3.7/site-packages/pdfforms/pdfforms.py", line 19, in inspect_pdfs
        field_defs[filename] = inspect_pdf_fields(filename)
      File "/home/fishcakedev/.virtualenvs/myvenv/lib/python3.7/site-packages/pdfforms/pdfforms.py", line 54, in inspect_pdf_fields
        p = run(cmd, stdout=PIPE, universal_newlines=True, check=True)
      File "/usr/lib/python3.7/subprocess.py", line 468, in run
        output=stdout, stderr=stderr)
    subprocess.CalledProcessError: Command '['pdftk', 'arbeitszeit.pdf', 'dump_data_fields', 'output', '-']' died with <Signals.SIGABRT: 6>.

Thanks -- that's useful. This new error suggests that pdfforms isn't compatible with our virtualization environment. However, the specific error is one that will be fixed by an update that we're planning to release later this month. Would you be interested in beta-testing it when it's available?

oh I see. well in that case I'd be definitely interested in beta testing it :)

Great! I've made a note of your interest.