summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xplanner_generator.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/planner_generator.py b/planner_generator.py
index 4850fd1..115e7d9 100755
--- a/planner_generator.py
+++ b/planner_generator.py
@@ -57,6 +57,8 @@ class Generator:
template or self.default_template
) + ".pdf"
+ self.paper_size = self._get_paper_size(template)
+
env = jinja2.Environment()
self.templates_dir = "templates"
loader = jinja2.FileSystemLoader(self.templates_dir)
@@ -66,7 +68,7 @@ class Generator:
self.template_verso = loader.load(env, template + "-v.svg")
self.template_cover = loader.load(
env,
- self._get_cover_name(template, cover_template)
+ self._get_cover_name(cover_template)
)
self.build_dir = build_dir
self.page_fname = os.path.join(
@@ -74,16 +76,19 @@ class Generator:
template + "-{year}-{page:03}.svg"
)
- def _get_cover_name(self, template, cover_template):
- if cover_template:
- return cover_template
+ def _get_paper_size(self, template):
if "A6" in template:
- return "cover-A6-r.svg"
+ return "a6"
if "A5" in template:
- return "cover-A5-r.svg"
+ return "a5"
if "A4" in template:
- return "cover-A4-r.svg"
- return "cover-A6-r.svg"
+ return "a4"
+ return "a6"
+
+ def _get_cover_name(self, cover_template):
+ if cover_template:
+ return cover_template
+ return "cover-{}-r.svg".format(self.paper_size.upper())
def render_page(self, page: int, **kw):
# page counts starts with 0
@@ -158,6 +163,8 @@ class Generator:
subprocess.run([
"pdfjam",
"--outfile", self.out_file,
+ "--scale", "1",
+ "--paper", "{}paper".format(self.paper_size),
*pdf_pages
])
except FileNotFoundError: