|
| 1 | +""" |
| 2 | +Remove pages from PDF files. |
| 3 | +
|
| 4 | +Page ranges refer to the previously-named file. |
| 5 | +A file not followed by a page range means all the pages of the file. |
| 6 | +
|
| 7 | +PAGE RANGES are like Python slices. |
| 8 | +
|
| 9 | + Remember, page indices start with zero. |
| 10 | +
|
| 11 | + Page range expression examples: |
| 12 | +
|
| 13 | + : all pages. -1 last page. |
| 14 | + 22 just the 23rd page. :-1 all but the last page. |
| 15 | + 0:3 the first three pages. -2 second-to-last page. |
| 16 | + :3 the first three pages. -2: last two pages. |
| 17 | + 5: from the sixth page onward. -3:-1 third & second to last. |
| 18 | +
|
| 19 | + The third, "stride" or "step" number is also recognized. |
| 20 | +
|
| 21 | + ::2 0 2 4 ... to the end. 3:0:-1 3 2 1 but not 0. |
| 22 | + 1:10:2 1 3 5 7 9 2::-1 2 1 0. |
| 23 | + ::-1 all pages in reverse order. |
| 24 | +
|
| 25 | +Examples |
| 26 | + pdfly rm -o output.pdf document.pdf 2:5 |
| 27 | +
|
| 28 | + Remove pages 2 to 4 from document.pdf, producing output.pdf. |
| 29 | +
|
| 30 | + pdfly rm document.pdf :-1 |
| 31 | +
|
| 32 | + Removes all pages except the last one from document.pdf, modifying the original file. |
| 33 | +
|
| 34 | + pdfly rm report.pdf :6 7: |
| 35 | +
|
| 36 | + Remove all pages except page seven from report.pdf, |
| 37 | + producing a single-page report.pdf. |
| 38 | +
|
| 39 | +""" |
| 40 | + |
| 41 | +from pathlib import Path |
| 42 | +from typing import List |
| 43 | + |
| 44 | +from pdfly.cat import main as cat_main |
| 45 | + |
| 46 | + |
| 47 | +def main( |
| 48 | + filename: Path, fn_pgrgs: List[str], output: Path, verbose: bool |
| 49 | +) -> None: |
| 50 | + cat_main(filename, fn_pgrgs, output, verbose, inverted_page_selection=True) |
0 commit comments