pdftools icon indicating copy to clipboard operation
pdftools copied to clipboard

add won't parse arguments the right way

Open stlehmann opened this issue 4 years ago • 4 comments

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

stlehmann avatar Sep 09 '20 06:09 stlehmann

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 avatar Dec 27 '22 00:12 kwmartin

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 avatar Dec 27 '22 01:12 kwmartin

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?

kwmartin avatar Dec 27 '22 01:12 kwmartin

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)

MartinThoma avatar Dec 30 '22 19:12 MartinThoma