stlehmann / pdftools

small collection of python scripts for pdf manipulation
MIT License
93 stars 19 forks source link

add won't parse arguments the right way #11

Open stlehmann opened 4 years ago

stlehmann commented 4 years ago

If I do something like this:

pdftools add -o output.pdf input.pdf

I will get the following error:

pdftools add: error: the following arguments are required: src

kwmartin commented 1 year ago

I have the same problem `

pdftools copy -p 208-209 dest.pdf sob_master_20221201.pdf usage: pdftools copy [-h] [-o OUTPUT] [-p PAGES [PAGES ...]] [-y] src pdftools copy: error: the following arguments are required: src and pdftools copy -o tmp.pdf -p 208-209 sob_master_20221201.pdf usage: pdftools copy [-h] [-o OUTPUT] [-p PAGES [PAGES ...]] [-y] src pdftools copy: error: the following arguments are required: src `

kwmartin commented 1 year ago

Looked into it a bit. 1) when using copy there is no dest, 2) the way the argument parser is written, the src file must be before the "flag" arguments., and 2) on line 266 of the version that comes in with pip, we have: pdf_copy(ARGS.input, ARGS.output, ARGS.pages, ARGS.y) as compared to the repo which has pdf_add(ARGS.dest, ARGS.src, ARGS.pages, ARGS.output). ARGS which is 'Namespace' object has no attribute 'input'. Basically, not currently useable at least with the version coming in with pip

kwmartin commented 1 year ago

Did a pip uninstall, cloned repo, did a sudo python3 setup.py install which worked. Tried running and got: PyPDF2.errors.DeprecationError: PdfFileReader is deprecated and was removed in PyPDF2 3.0.0. Use PdfReader instead. Oh well! I guess you get what you pay for?

MartinThoma commented 1 year ago

Here are your options:

  1. Downgrade to PyPDF2<3.0.0
  2. Upgrade your code (replace PdfFileReader by PdfReader; potentially more); see https://github.com/stlehmann/pdftools/issues/17
  3. Replace PyPDF2 by pypdf + step (2)