Skip to content

Commit 51fc9e5

Browse files
committed
Added option to export PDF
1 parent 13207f7 commit 51fc9e5

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

export_book.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
import natsort
88
import re
99

10-
parser = argparse.ArgumentParser(description='Export book to PDF')
10+
parser = argparse.ArgumentParser(description='Export book')
1111
parser.add_argument("-ch", type=int, help="Chapter to export", default="99")
12+
parser.add_argument("-pdf", help="Export for PDF print", action="store_true", default=False)
1213
parser.add_argument("-paperback", help="Export for paperback print", action="store_true", default=False)
1314
parser.add_argument("-kindle", help="Export the kindle version", action="store_true", default=False)
1415
parser.add_argument("-v", help="verbose", action="store_true", default=False)
@@ -58,13 +59,16 @@ def get_list_of_files(path, extension):
5859
pandoc_cmd = pandoc_cmd + "-V geometry:top=1.5cm "
5960
pandoc_cmd = pandoc_cmd + "-V geometry:bottom=1.5cm "
6061
pandoc_cmd = pandoc_cmd + "-V fontsize:12pt "
61-
else:
62-
pandoc_cmd = pandoc_cmd + "--include-before-body cover.tex "
62+
elif args.pdf:
63+
#pandoc_cmd = pandoc_cmd + "--include-before-body cover.tex "
64+
pandoc_cmd = pandoc_cmd + "-V classoption=twoside "
65+
pandoc_cmd = pandoc_cmd + "-V geometry:paperwidth=169.90mm "
66+
pandoc_cmd = pandoc_cmd + "-V geometry:paperheight=244.10mm "
6367
pandoc_cmd = pandoc_cmd + "-V geometry:left=2cm "
6468
pandoc_cmd = pandoc_cmd + "-V geometry:right=2cm "
6569
pandoc_cmd = pandoc_cmd + "-V geometry:top=2cm "
6670
pandoc_cmd = pandoc_cmd + "-V geometry:bottom=2cm "
67-
pandoc_cmd = pandoc_cmd + "-V fontsize:10pt "
71+
pandoc_cmd = pandoc_cmd + "-V fontsize:8pt "
6872

6973
pandoc_cmd = pandoc_cmd + "--filter pandoc-fignos --filter pandoc-tablenos --filter pandoc-crossref --natbib -o book.tex metadata.txt "
7074

@@ -102,7 +106,7 @@ def get_list_of_files(path, extension):
102106
addTabularnewlineTablePerfMetrics = False
103107
for line in lines:
104108
# change font size in listings for paperback
105-
if (args.paperback or args.kindle) and "basicstyle=\\ttfamily," in line:
109+
if (args.paperback or args.kindle or args.pdf) and "basicstyle=\\ttfamily," in line:
106110
g.write(line.replace("basicstyle=\\ttfamily,", "basicstyle=\\lst@ifdisplaystyle\\footnotesize\\fi\\ttfamily,"))
107111
# workaround for citations and bibliography
108112
elif "\\usepackage[]{natbib}" in line:

0 commit comments

Comments
 (0)