py-pdf / pdfly

CLI tool to extract (meta)data from PDF and manipulate PDF files
BSD 3-Clause "New" or "Revised" License
89 stars 11 forks source link

cat command fails to execute with negative page slice #44

Open capricorn opened 7 months ago

capricorn commented 7 months ago
$ python3 -m pdfly --version
pdfly 0.3.0
  using pypdf==4.0.2

My understanding is that the following command should extract the last page of the PDF:

$ python3 -m pdfly cat resources/GeoBase_NHNC1_Data_Model_UML_EN.pdf -o geo.pdf -1
Error
No such option: -1

I've tried passing the quoted form '-1' as well but that doesn't seem to help. Positive integers work just fine.

Ranges also fail:

$ python3 -m pdfly cat resources/GeoBase_NHNC1_Data_Model_UML_EN.pdf -o geo.pdf -2:
Error
No such option: -2
capricorn commented 7 months ago

Well, following https://github.com/tiangolo/typer/issues/134#issuecomment-654286948 this works:

$ pdfly cat resources/GeoBase_NHNC1_Data_Model_UML_EN.pdf -o /tmp/geo.pdf -- -1

In that case the examples for $ pdfly cat --help just need updated?