diff options
author | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2024-09-02 15:10:26 +0200 |
---|---|---|
committer | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2024-09-02 15:10:26 +0200 |
commit | f9345021f03ee7925a30c56cbb57b68d735ba213 (patch) | |
tree | b0fdc2cb8f851ab0c8fda7a672e8dccf13c360e7 | |
parent | 3ee00e87564045defc10400304f3ec2d481770cb (diff) |
Add support for arbitrary sizes
-rwxr-xr-x | planner/planner_generator.py | 19 | ||||
-rw-r--r-- | planner/templates/cover-95×186-r.svg | 97 | ||||
-rw-r--r-- | planner/templates/daily-95×186-r.svg | 113 | ||||
-rw-r--r-- | planner/templates/daily-95×186-v.svg | 113 |
4 files changed, 337 insertions, 5 deletions
diff --git a/planner/planner_generator.py b/planner/planner_generator.py index 906c0fc..2da3133 100755 --- a/planner/planner_generator.py +++ b/planner/planner_generator.py @@ -6,6 +6,7 @@ import datetime import locale import logging import os +import re import shutil import subprocess import sys @@ -87,6 +88,8 @@ class Generator: return "a5" if "A4" in template: return "a4" + if "×" in template: + return re.findall(r"\d+×\d+", template)[0] return "a6" def _get_cover_name(self, cover_template): @@ -163,14 +166,20 @@ class Generator: def join_pages(self): pdf_pages = self.get_pdf_pages() - try: - subprocess.run([ + command = [ "pdfjam", "--outfile", self.out_file, "--scale", "1", - "--paper", "{}paper".format(self.paper_size), - *pdf_pages - ]) + ] + if "×" in self.paper_size: + x, y = self.paper_size.split("×") + size = "{" + x + "mm," + y + "mm}" + command.extend(["--papersize", size]) + else: + command.extend(["--paper", "{}paper".format(self.paper_size)]) + command.extend(pdf_pages) + try: + subprocess.run(command) except FileNotFoundError: logging.warning("pdfjam is not installed") logging.warning("you will have to join the pdf pages yourself") diff --git a/planner/templates/cover-95×186-r.svg b/planner/templates/cover-95×186-r.svg new file mode 100644 index 0000000..615745b --- /dev/null +++ b/planner/templates/cover-95×186-r.svg @@ -0,0 +1,97 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + width="95mm" + height="186mm" + viewBox="0 0 359.05511 702.99214" + version="1.1" + id="svg5" + inkscape:version="1.2.2 (b0a8486541, 2022-12-01)" + sodipodi:docname="cover-hobonichi-r.svg" + inkscape:export-filename="/home/valhalla/projects/software/pdfscripts/pdfscripts/templates/week_on_two_pages-A6-v.png" + inkscape:export-xdpi="96" + inkscape:export-ydpi="96" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg"> + <sodipodi:namedview + id="namedview7" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageshadow="2" + inkscape:pageopacity="0.0" + inkscape:pagecheckerboard="0" + inkscape:document-units="mm" + showgrid="true" + inkscape:zoom="0.72949405" + inkscape:cx="246.06095" + inkscape:cy="396.85039" + inkscape:window-width="1161" + inkscape:window-height="830" + inkscape:window-x="117" + inkscape:window-y="56" + inkscape:window-maximized="0" + inkscape:current-layer="layer1" + showguides="true" + inkscape:guide-bbox="true" + inkscape:showpageshadow="2" + inkscape:deskcolor="#d1d1d1"> + <inkscape:grid + type="xygrid" + id="grid9" + units="mm" + spacingx="3.7795276" + spacingy="3.7795276" + originx="0" + originy="0" /> + <sodipodi:guide + position="0,449.76378" + orientation="0,1" + id="guide1474" + inkscape:label="" + inkscape:locked="false" + inkscape:color="rgb(0,0,255)" /> + <sodipodi:guide + position="0,-71.811024" + orientation="0,1" + id="guide1476" + inkscape:label="" + inkscape:locked="false" + inkscape:color="rgb(0,0,255)" /> + <sodipodi:guide + position="37.795276,468.66142" + orientation="-1,0" + id="guide1478" + inkscape:label="" + inkscape:locked="false" + inkscape:color="rgb(0,0,255)" /> + <sodipodi:guide + position="340.15748,702.99213" + orientation="-1,0" + id="guide1480" + inkscape:label="" + inkscape:locked="false" + inkscape:color="rgb(0,0,255)" /> + </sodipodi:namedview> + <defs + id="defs2" /> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> + <text + xml:space="preserve" + style="font-style:normal;font-weight:normal;font-size:32px;line-height:1.25;font-family:sans-serif;text-align:center;text-anchor:middle;fill:#404040;fill-opacity:1;stroke:none" + x="179.51193" + y="256.14908" + id="text7108"><tspan + sodipodi:role="line" + id="tspan7106" + x="179.51193" + y="256.14908" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:32px;font-family:Gentium;-inkscape-font-specification:'Gentium, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:center;text-anchor:middle;fill:#404040;fill-opacity:1">{{ year }}</tspan></text> + </g> +</svg> diff --git a/planner/templates/daily-95×186-r.svg b/planner/templates/daily-95×186-r.svg new file mode 100644 index 0000000..660d31f --- /dev/null +++ b/planner/templates/daily-95×186-r.svg @@ -0,0 +1,113 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + width="95mm" + height="186mm" + viewBox="0 0 359.05511 702.99214" + version="1.1" + id="svg5" + inkscape:version="1.2.2 (b0a8486541, 2022-12-01)" + sodipodi:docname="daily-hobonichi-r.svg" + inkscape:export-filename="/home/valhalla/projects/software/pdfscripts/pdfscripts/templates/week_on_two_pages-A6-v.png" + inkscape:export-xdpi="96" + inkscape:export-ydpi="96" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg"> + <sodipodi:namedview + id="namedview7" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageshadow="2" + inkscape:pageopacity="0.0" + inkscape:pagecheckerboard="0" + inkscape:document-units="mm" + showgrid="true" + inkscape:zoom="1.58" + inkscape:cx="366.77215" + inkscape:cy="76.898734" + inkscape:window-width="1724" + inkscape:window-height="926" + inkscape:window-x="42" + inkscape:window-y="0" + inkscape:window-maximized="0" + inkscape:current-layer="layer1" + showguides="true" + inkscape:guide-bbox="true" + inkscape:showpageshadow="2" + inkscape:deskcolor="#d1d1d1"> + <inkscape:grid + type="xygrid" + id="grid9" + units="mm" + spacingx="3.7795276" + spacingy="3.7795276" + originx="0" + originy="0" /> + <sodipodi:guide + position="0,449.76378" + orientation="0,1" + id="guide1474" + inkscape:label="" + inkscape:locked="false" + inkscape:color="rgb(0,0,255)" /> + <sodipodi:guide + position="0,-71.811024" + orientation="0,1" + id="guide1476" + inkscape:label="" + inkscape:locked="false" + inkscape:color="rgb(0,0,255)" /> + <sodipodi:guide + position="37.795276,468.66142" + orientation="-1,0" + id="guide1478" + inkscape:label="" + inkscape:locked="false" + inkscape:color="rgb(0,0,255)" /> + <sodipodi:guide + position="540.47244,702.99213" + orientation="-1,0" + id="guide1480" + inkscape:label="" + inkscape:locked="false" + inkscape:color="rgb(0,0,255)" /> + </sodipodi:namedview> + <defs + id="defs2" /> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> + <path + style="fill:none;stroke:#7f7f7f;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 37.795278,56.692914 302.362212,0" + id="path1562-3-7" + sodipodi:nodetypes="cc" /> + <text + xml:space="preserve" + style="font-style:normal;font-weight:normal;font-size:21.3333px;line-height:1.25;font-family:sans-serif;text-align:start;text-anchor:start;fill:#404040;fill-opacity:1;stroke:none" + x="36.735123" + y="45.264271" + id="text7108"><tspan + sodipodi:role="line" + id="tspan7106" + x="36.735123" + y="45.264271" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:21.3333px;font-family:Gentium;-inkscape-font-specification:'Gentium, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:start;text-anchor:start;fill:#404040;fill-opacity:1">{{ day.strftime("%A") }}</tspan></text> + <text + xml:space="preserve" + style="font-style:normal;font-weight:normal;font-size:21.3333px;line-height:1.25;font-family:sans-serif;text-align:end;text-anchor:end;fill:#404040;fill-opacity:1;stroke:none" + x="341.19913" + y="45.230762" + id="text7108-3"><tspan + sodipodi:role="line" + id="tspan7106-5" + x="341.19913" + y="45.230762" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:21.3333px;font-family:Gentium;-inkscape-font-specification:'Gentium, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:end;text-anchor:end;fill:#404040;fill-opacity:1">{{ day.strftime("%d %B %Y").strip('0') }}</tspan></text> + </g> +</svg> diff --git a/planner/templates/daily-95×186-v.svg b/planner/templates/daily-95×186-v.svg new file mode 100644 index 0000000..4400c4e --- /dev/null +++ b/planner/templates/daily-95×186-v.svg @@ -0,0 +1,113 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + width="95mm" + height="186mm" + viewBox="0 0 359.05511 702.99214" + version="1.1" + id="svg5" + inkscape:version="1.2.2 (b0a8486541, 2022-12-01)" + sodipodi:docname="daily-hobonichi-v.svg" + inkscape:export-filename="/home/valhalla/projects/software/pdfscripts/pdfscripts/templates/week_on_two_pages-A6-v.png" + inkscape:export-xdpi="96" + inkscape:export-ydpi="96" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg"> + <sodipodi:namedview + id="namedview7" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageshadow="2" + inkscape:pageopacity="0.0" + inkscape:pagecheckerboard="0" + inkscape:document-units="mm" + showgrid="true" + inkscape:zoom="1.58" + inkscape:cx="269.3038" + inkscape:cy="137.97468" + inkscape:window-width="1678" + inkscape:window-height="895" + inkscape:window-x="63" + inkscape:window-y="0" + inkscape:window-maximized="0" + inkscape:current-layer="layer1" + showguides="true" + inkscape:guide-bbox="true" + inkscape:showpageshadow="2" + inkscape:deskcolor="#d1d1d1"> + <inkscape:grid + type="xygrid" + id="grid9" + units="mm" + spacingx="3.7795276" + spacingy="3.7795276" + originx="0" + originy="0" /> + <sodipodi:guide + position="0,449.76378" + orientation="0,1" + id="guide1474" + inkscape:label="" + inkscape:locked="false" + inkscape:color="rgb(0,0,255)" /> + <sodipodi:guide + position="0,-71.811024" + orientation="0,1" + id="guide1476" + inkscape:label="" + inkscape:locked="false" + inkscape:color="rgb(0,0,255)" /> + <sodipodi:guide + position="18.897638,468.66142" + orientation="-1,0" + id="guide1478" + inkscape:label="" + inkscape:locked="false" + inkscape:color="rgb(0,0,255)" /> + <sodipodi:guide + position="340.15748,702.99213" + orientation="-1,0" + id="guide1480" + inkscape:label="" + inkscape:locked="false" + inkscape:color="rgb(0,0,255)" /> + </sodipodi:namedview> + <defs + id="defs2" /> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> + <path + style="fill:none;stroke:#7f7f7f;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 18.897638,56.692914 321.259852,0" + id="path1562-3-7" + sodipodi:nodetypes="cc" /> + <text + xml:space="preserve" + style="font-style:normal;font-weight:normal;font-size:21.3333px;line-height:1.25;font-family:sans-serif;text-align:start;text-anchor:start;fill:#404040;fill-opacity:1;stroke:none" + x="17.015612" + y="45.230762" + id="text7108-3"><tspan + sodipodi:role="line" + id="tspan7106-5" + x="17.015612" + y="45.230762" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:21.3333px;font-family:Gentium;-inkscape-font-specification:'Gentium, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:start;text-anchor:start;fill:#404040;fill-opacity:1">{{ day.strftime("%d %B %Y").strip('0') }}</tspan></text> + <text + xml:space="preserve" + style="font-style:normal;font-weight:normal;font-size:21.3333px;line-height:1.25;font-family:sans-serif;text-align:end;text-anchor:end;fill:#404040;fill-opacity:1;stroke:none" + x="341.19916" + y="45.264271" + id="text7108"><tspan + sodipodi:role="line" + id="tspan7106" + x="341.19916" + y="45.264271" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:21.3333px;font-family:Gentium;-inkscape-font-specification:'Gentium, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:end;text-anchor:end;fill:#404040;fill-opacity:1">{{ day.strftime("%A") }}</tspan></text> + </g> +</svg> |