这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录 前一修订版 后一修订版 | 前一修订版 后一修订版 两侧同时换到之后的修订记录 | ||
python-files:pdf-calendar [2017/04/01 05:01] admin |
python-files:pdf-calendar [2017/04/01 06:01] admin [Reference] |
||
---|---|---|---|
行 1: | 行 1: | ||
====== Python 使用reportlab 创建PDF格式日历 ====== | ====== Python 使用reportlab 创建PDF格式日历 ====== | ||
+ | |||
+ | 使用到的模块有: | ||
+ | |||
+ | * calendar (python self contained) | ||
+ | * reportlab | ||
在源代码里面增加了字体部分: | 在源代码里面增加了字体部分: | ||
行 60: | 行 65: | ||
raise NoCanvasError | raise NoCanvasError | ||
monthname = time.strftime("%B", time.strptime(str(month), "%m")) | monthname = time.strftime("%B", time.strptime(str(month), "%m")) | ||
+ | calendar.setfirstweekday(calendar.SUNDAY) | ||
cal = calendar.monthcalendar(year, month) | cal = calendar.monthcalendar(year, month) | ||
行 128: | 行 134: | ||
if __name__ == "__main__": | if __name__ == "__main__": | ||
#create a December, 2005 PDF | #create a December, 2005 PDF | ||
- | c = createCalendar(12, 2005, filename="blog_calendar.pdf") | + | c = createCalendar(4, 2017, filename="blog_calendar.pdf") |
#now add January, 2006 to the end | #now add January, 2006 to the end | ||
- | createCalendar(1, 2006, canvas=c) | + | createCalendar(5, 2017, canvas=c) |
c.save() | c.save() | ||
行 136: | 行 142: | ||
===== Reference ===== | ===== Reference ===== | ||
- | * https://billmill.org/static/files/pdf_calendar.py | + | * https://billmill.org/static/files/pdf_calendar.py [[python-files:pdf-calendar-orignal-ref-back]] |
* http://stackoverflow.com/questions/7276017/producing-a-printable-calendar-with-python | * http://stackoverflow.com/questions/7276017/producing-a-printable-calendar-with-python | ||