forked from stlehmann/pdftools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpdfinsert.py
More file actions
executable file
·51 lines (44 loc) · 1.7 KB
/
Copy pathpdfinsert.py
File metadata and controls
executable file
·51 lines (44 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python
import sys
import argparse
from pdftools import pdf_insert
from pdftools.parseutil import parentparser
def process_arguments(args):
parser = argparse.ArgumentParser(
parents=[parentparser],
description="Insert pages of one file in another."
)
# destination
parser.add_argument('dest',
type=str,
help='destination pdf file')
# source
parser.add_argument('source',
type=str,
help='source pdf file')
# output
parser.add_argument('-o',
'--output',
type=str,
default=None,
help='filename of the output files, if None given '
'dest will be used as output')
# pages
parser.add_argument('-p',
'--pages',
nargs='+',
help='list of page numbers (start with 1) which will be'
' inserted, if None all pages will be rotated '
'(default), Examples: 5 1-9 1- -9')
# index
parser.add_argument('-i',
'--index',
type=int,
default=None,
help='page number (start with 1) of destination file '
'where the pages will be inserted, if None they '
'will be added at the end of the file ')
return parser.parse_args(args)
if __name__ == "__main__":
args = process_arguments(sys.argv[1:])
pdf_insert(args.dest, args.source, args.pages, args.index, args.output)