Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ pdftools
[![Downloads](https://pepy.tech/badge/pdftools)](https://pepy.tech/project/pdftools)
[![Downloads](https://pepy.tech/badge/pdftools/week)](https://pepy.tech/project/pdftools/week)

## local install

`pip install .`

do not use `setup.py install`

## Features

* add, insert, remove and rotate pages
Expand Down
6 changes: 5 additions & 1 deletion pdftools/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ def main():
default=None,
help="Name of the output file. If None, the `src` file will be overwritten",
)
parser_remove.add_argument(
"-f", "--force",
action="store_true",
help='Caution!! Answers "Yes" to all overwrite queries.')

# Rotate
# --------------------------------------------
Expand Down Expand Up @@ -275,7 +279,7 @@ def main():
elif ARGS.command == "remove":
from pdftools.pdftools import pdf_remove

pdf_remove(ARGS.src, ARGS.pages, ARGS.output)
pdf_remove(ARGS.src, ARGS.pages, ARGS.output, ARGS.force)
elif ARGS.command == "rotate":
from pdftools.pdftools import pdf_rotate

Expand Down
4 changes: 2 additions & 2 deletions pdftools/pdftools.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def pdf_insert(
srcfile.close()


def pdf_remove(source: str, pages: [str], output: str = None):
def pdf_remove(source: str, pages: [str], output: str = None, yes_to_all=False):
"""
Remove pages from a PDF source file.
:param source: pdf source file
Expand Down Expand Up @@ -346,7 +346,7 @@ def pdf_remove(source: str, pages: [str], output: str = None):

# Move temporary file to source
if output is None:
if overwrite_dlg(source):
if yes_to_all or overwrite_dlg(source):
os.remove(source)
move(outfile.name, source)
else:
Expand Down