用户工具

站点工具


python-files:pdf-calendar

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

后一修订版
前一修订版
后一修订版 两侧同时换到之后的修订记录
python-files:pdf-calendar [2017/04/01 04:59]
admin 创建
python-files:pdf-calendar [2017/04/01 05:22]
admin [Python 源代码]
行 1: 行 1:
 ====== Python 使用reportlab 创建PDF格式日历 ====== ====== Python 使用reportlab 创建PDF格式日历 ======
  
 +使用到的模块有:
 +
 +  * calendar (python self contained)
 +  * reportlab
 +
 +在源代码里面增加了字体部分:
 +<​code>​
 +    canvas.setFont("​Times-Roman",​ 20)
 +</​code>​
  
 ===== Python 源代码 ===== ===== Python 源代码 =====
行 56: 行 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)
  
行 124: 行 134:
 if __name__ == "​__main__":​ if __name__ == "​__main__":​
     #create a December, 2005 PDF     #create a December, 2005 PDF
-    c = createCalendar(122005, filename="​blog_calendar.pdf"​)+    c = createCalendar(42017, filename="​blog_calendar.pdf"​)
     #now add January, 2006 to the end     #now add January, 2006 to the end
-    createCalendar(12006, canvas=c)+    createCalendar(52017, canvas=c)
     c.save()     c.save()
  
 </​code>​ </​code>​
  
 +===== Reference ===== 
 +  * https://​billmill.org/​static/​files/​pdf_calendar.py 
 +  * http://​stackoverflow.com/​questions/​7276017/​producing-a-printable-calendar-with-python
  
python-files/pdf-calendar.txt · 最后更改: 2017/04/01 06:08 由 admin