Skip to content

Instantly share code, notes, and snippets.

@keichi
Created November 22, 2017 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keichi/e6b3d62f7ca15c101bc076d8a0375f24 to your computer and use it in GitHub Desktop.
Save keichi/e6b3d62f7ca15c101bc076d8a0375f24 to your computer and use it in GitHub Desktop.
卒論カウントダウンカレンダー
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