diff options
author | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2022-07-08 11:40:55 +0200 |
---|---|---|
committer | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2022-07-08 11:40:55 +0200 |
commit | 06fd90917fdccd7ae777d10bdd9a1c8e4319c4ea (patch) | |
tree | 9682d000bcb7675b88e72f6dd6f7ed502e2fcf07 /planner_generator.py | |
parent | a7d56b4798223357ad47857966da1a748c6d0983 (diff) |
Set the right paper size in the final file
Diffstat (limited to 'planner_generator.py')
-rwxr-xr-x | planner_generator.py | 23 |
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: |