Ursprung
5c960b1b6b
Commit
216d9c2668
2 geänderte Dateien mit 22 neuen und 2 gelöschten Zeilen
|
@ -19,7 +19,7 @@ You can now use the `pdf-sign` tool interactively (or non-interactively) to sign
|
||||||
Run `pdf-sign -h` or `pdf-create-empty -h` for details.
|
Run `pdf-sign -h` or `pdf-create-empty -h` for details.
|
||||||
|
|
||||||
Installation:
|
Installation:
|
||||||
* Install dependencies: `gs`, `mv`, `pdfinfo`, `pdftk`, `python3` and python3 module `tkinter`.
|
* Install dependencies: `python3.7` or later with module `tkinter`, `gs` (Ghostscript), `pdftk` and `pdfinfo`.
|
||||||
* Copy one or both tools to a directory in your `$PATH`.
|
* Copy one or both tools to a directory in your `$PATH`.
|
||||||
|
|
||||||
Installation on Debian:
|
Installation on Debian:
|
||||||
|
|
22
pdf-sign
22
pdf-sign
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
#Dependencies: python3, pdftk, gs, mv, pdfinfo
|
#Dependencies: python3.7 or later with module tkinter, gs (Ghostscript), pdftk and pdfinfo.
|
||||||
|
|
||||||
import argparse, os, queue, re, subprocess, sys, tempfile, time
|
import argparse, os, queue, re, subprocess, sys, tempfile, time
|
||||||
|
|
||||||
|
@ -359,6 +359,26 @@ def die(reason):
|
||||||
print(reason, file=sys.stderr)
|
print(reason, file=sys.stderr)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
|
# Monkey-patch argparse if necessary
|
||||||
|
if not 'BooleanOptionalAction' in dir(argparse):
|
||||||
|
class BooleanOptionalAction(argparse.Action):
|
||||||
|
def __init__(self, option_strings, dest, default=None, type=None, choices=None, required=False, help=None, metavar=None):
|
||||||
|
_option_strings = []
|
||||||
|
for option_string in option_strings:
|
||||||
|
_option_strings.append(option_string)
|
||||||
|
if option_string.startswith('--'):
|
||||||
|
option_string = '--no-' + option_string[2:]
|
||||||
|
_option_strings.append(option_string)
|
||||||
|
if help is not None and default is not None:
|
||||||
|
help += f" (default: {default})"
|
||||||
|
super().__init__(option_strings=_option_strings, dest=dest, nargs=0, default=default, type=type, choices=choices, required=required, help=help, metavar=metavar)
|
||||||
|
def __call__(self, _parser, namespace, values, option_string=None):
|
||||||
|
if option_string in self.option_strings:
|
||||||
|
setattr(namespace, self.dest, not option_string.startswith('--no-'))
|
||||||
|
def format_usage(self):
|
||||||
|
return ' | '.join(self.option_strings)
|
||||||
|
argparse.BooleanOptionalAction = BooleanOptionalAction
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Sign a PDF file.')
|
parser = argparse.ArgumentParser(description='Sign a PDF file.')
|
||||||
parser.add_argument('input', metavar='input.pdf', type=str, help='Input PDF file.')
|
parser.add_argument('input', metavar='input.pdf', type=str, help='Input PDF file.')
|
||||||
parser.add_argument('-p', '--page', type=int, default=-1, help='The page to sign, negative for counting from the end. (default: -1)')
|
parser.add_argument('-p', '--page', type=int, default=-1, help='The page to sign, negative for counting from the end. (default: -1)')
|
||||||
|
|
Laden …
Tabelle hinzufügen
In neuem Issue referenzieren