Created
November 22, 2017 08:54
-
-
Save keichi/e6b3d62f7ca15c101bc076d8a0375f24 to your computer and use it in GitHub Desktop.
卒論カウントダウンカレンダー
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
from reportlab.pdfgen import canvas | |
from reportlab.lib.units import mm | |
from reportlab.pdfbase.pdfmetrics import registerFont | |
from reportlab.pdfbase.cidfonts import UnicodeCIDFont | |
XDAY = datetime.datetime(2018, 2, 19) | |
if __name__ == "__main__": | |
registerFont(UnicodeCIDFont("HeiseiKakuGo-W5")) | |
c = canvas.Canvas("calendar.pdf") | |
c.setPageSize((210.0 * mm, 297.0 * mm)) | |
for i in range(100): | |
if i % 4 == 0: | |
offx = 0.0 * mm | |
offy = 148.5 * mm | |
elif i % 4 == 1: | |
offx = 105.0 * mm | |
offy = 148.5 * mm | |
elif i % 4 == 2: | |
offx = 0.0 * mm | |
offy = 0.0 * mm | |
elif i % 4 == 3: | |
offx = 105.0 * mm | |
offy = 0.0 * mm | |
c.setFont("HeiseiKakuGo-W5", 30) | |
c.drawString(10.0 * mm + offx, 110.0 * mm + offy, "卒論発表まであと") | |
c.setFont("HeiseiKakuGo-W5", 130) | |
c.drawString(10.0 * mm + offx, 60.0 * mm + offy, "{0:2}".format(i)) | |
c.setFont("HeiseiKakuGo-W5", 60) | |
c.drawString(70.0 * mm + offx, 60.0 * mm + offy, "日") | |
c.line(10.0 * mm + offx, 57.0 * mm + offy, | |
90.0 * mm + offx, 57.0 * mm + offy) | |
today = XDAY - datetime.timedelta(i) | |
c.setFont("HeiseiKakuGo-W5", 30) | |
c.drawString(10.0 * mm + offx, 10.0 * mm + offy, | |
today.strftime("%Y年%m月%d日")) | |
if i % 4 == 0: | |
c.line(105.0 * mm, 0.0 * mm, 105.0 * mm, 297.0 * mm) | |
c.line(0.0 * mm, 148.5 * mm, 210.0 * mm, 148.5 * mm) | |
c.showPage() | |
c.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment