Skip to content

Commit 0823be1

Browse files
authored
DOC: add documentation about how to use negative page ranges in cat/rm/rotate (#168)
1 parent 4aab1b4 commit 0823be1

6 files changed

Lines changed: 46 additions & 7 deletions

File tree

docs/user/subcommand-cat.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ pdfly cat --help
1616
range means all the pages of the file.
1717
PAGE RANGES are like Python slices.
1818
Remember, page indices start with zero.
19+
When using page ranges that start with a negative value a
20+
two-hyphen symbol -- must be used to separate them from
21+
the command line options.
1922
Page range expression examples:
2023
2124
: all pages.
@@ -39,7 +42,7 @@ pdfly cat --help
3942
4043
4144
Examples
42-
pdfly cat -o output.pdf head.pdf content.pdf :6 7: tail.pdf -1
45+
pdfly cat -o output.pdf head.pdf -- content.pdf :6 7: tail.pdf -1
4346
Concatenate all of head.pdf, all but page seven of content.pdf,
4447
and the last page of tail.pdf, producing output.pdf.
4548

docs/user/subcommand-rm.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ Usage: pdfly rm [OPTIONS] FILENAME FN_PGRGS...
1010
1111
Remove pages from PDF files.
1212
13-
Page ranges refer to the previously-named file.
13+
Page ranges refer to the previously-named file.
1414
A file not followed by a page range means all the pages of the file.
1515
1616
PAGE RANGES are like Python slices.
17-
17+
1818
Remember, page indices start with zero.
1919
20+
When using page ranges that start with a negative value a
21+
two-hyphen symbol -- must be used to separate them from
22+
the command line options.
23+
2024
Page range expression examples:
2125
2226
: all pages. -1 last page.
@@ -44,7 +48,7 @@ Usage: pdfly rm [OPTIONS] FILENAME FN_PGRGS...
4448
4549
Remove all pages except page seven from report.pdf,
4650
producing a single-page report.pdf.
47-
51+
4852
╭─ Arguments ─────────────────────────────────────────────────────────────────────────────────────────────╮
4953
│ * filename FILE [default: None] [required] │
5054
│ * fn_pgrgs FN_PGRGS... filenames and/or page ranges [default: None] [required] │
@@ -68,6 +72,6 @@ pdfly rm document.pdf 4
6872
Remove the first and last page of `document.pdf`, producing `output.pdf`.
6973

7074
```
71-
pdfly rm -o output.pdf document.pdf 1:-1
75+
pdfly rm -o output.pdf document.pdf 1:-1
7276
73-
```
77+
```

docs/user/subcommand-rotate.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,22 @@ pdfly rotate --help
1313
pdfly rotate --output output.pdf input.pdf 90
1414
Rotate all pages by 90 degrees (clockwise)
1515
16+
pdfly rotate --output output.pdf input.pdf 90 :3
17+
Rotate first three pages by 90 degrees (clockwise)
18+
19+
pdfly rotate --output output.pdf input.pdf 90 -- -1
20+
Rotate last page by 90 degrees (clockwise)
21+
1622
A file not followed by a page range (PGRGS) means all the pages of the file.
1723
1824
PAGE RANGES are like Python slices.
1925
2026
Remember, page indices start with zero.
2127
28+
When using page ranges that start with a negative value a
29+
two-hyphen symbol -- must be used to separate them from
30+
the command line options.
31+
2232
Page range expression examples:
2333
2434
: all pages. -1 last page.

pdfly/cat.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
99
Remember, page indices start with zero.
1010
11+
When using page ranges that start with a negative value a
12+
two-hyphen symbol -- must be used to separate them from
13+
the command line options.
14+
1115
Page range expression examples:
1216
1317
: all pages. -1 last page.
@@ -23,7 +27,7 @@
2327
::-1 all pages in reverse order.
2428
2529
Examples
26-
pdfly cat -o output.pdf head.pdf content.pdf :6 7: tail.pdf -1
30+
pdfly cat -o output.pdf head.pdf -- content.pdf :6 7: tail.pdf -1
2731
2832
Concatenate all of head.pdf, all but page seven of content.pdf,
2933
and the last page of tail.pdf, producing output.pdf.

pdfly/rm.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
99
Remember, page indices start with zero.
1010
11+
When using page ranges that start with a negative value a
12+
two-hyphen symbol -- must be used to separate them from
13+
the command line options.
14+
1115
Page range expression examples:
1216
1317
: all pages. -1 last page.
@@ -27,6 +31,10 @@
2731
2832
Remove pages 2 to 4 from document.pdf, producing output.pdf.
2933
34+
pdfly rm document.pdf -- -1
35+
36+
Removes the last page from document.pdf, modifying the original file.
37+
3038
pdfly rm document.pdf :-1
3139
3240
Removes all pages except the last one from document.pdf, modifying the original file.

pdfly/rotate.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,22 @@
55
pdfly rotate --output output.pdf input.pdf 90
66
Rotate all pages by 90 degrees (clockwise)
77
8+
pdfly rotate --output output.pdf input.pdf 90 :3
9+
Rotate first three pages by 90 degrees (clockwise)
10+
11+
pdfly rotate --output output.pdf input.pdf 90 -- -1
12+
Rotate last page by 90 degrees (clockwise)
13+
814
A file not followed by a page range (PGRGS) means all the pages of the file.
915
1016
PAGE RANGES are like Python slices.
1117
1218
Remember, page indices start with zero.
1319
20+
When using page ranges that start with a negative value a
21+
two-hyphen symbol -- must be used to separate them from
22+
the command line options.
23+
1424
Page range expression examples:
1525
1626
: all pages. -1 last page.

0 commit comments

Comments
 (0)