Welcome, guest | Sign In | My Account | Store | Cart
import fitz
import calendar
import sys
assert len(sys.argv) == 2, "need start year as the one and only parameter"

startyear = sys.argv[1]
assert startyear.isdigit(), "year must be positive numeric"
startyear = int(startyear)
assert startyear > 0, "year must be positive numeric"
    
doc = fitz.open()
cal = calendar.LocaleTextCalendar(locale = "de")   # choose your locale
w, h = fitz.PaperSize("a4-l")                      # get sizes for A4 landscape paper

txt = cal.formatyear(startyear, m = 4)
doc.insertPage(-1, txt, fontsize = 12, fontname = "Courier", width = w, height = h)

txt = cal.formatyear(startyear + 1, m = 4)
doc.insertPage(-1, txt, fontsize = 12, fontname = "Courier", width = w, height = h)

txt = cal.formatyear(startyear + 2, m = 4)
doc.insertPage(-1, txt, fontsize = 12, fontname = "Courier", width = w, height = h)

doc.save("Kalender.pdf", garbage = 4, deflate = True)

Diff to Previous Revision

--- revision 1 2017-06-11 15:05:07
+++ revision 2 2017-06-13 10:57:34
@@ -1,23 +1,24 @@
-import fitz                  # PyMuPDF
+import fitz
 import calendar
 import sys
 assert len(sys.argv) == 2, "need start year as the one and only parameter"
 
 startyear = sys.argv[1]
-assert startyear.isnumeric(), "year must be positive numeric"
+assert startyear.isdigit(), "year must be positive numeric"
 startyear = int(startyear)
 assert startyear > 0, "year must be positive numeric"
     
-doc = fitz.open()            # new empty PDF
-cal = calendar.LocaleTextCalendar(locale = "de")     # choose your locale
+doc = fitz.open()
+cal = calendar.LocaleTextCalendar(locale = "de")   # choose your locale
+w, h = fitz.PaperSize("a4-l")                      # get sizes for A4 landscape paper
 
-txt = cal.formatyear(startyear, m = 4, c = 10)
-doc.insertPage(-1, txt, fontname = "Courier", width = 842, height = 595)
+txt = cal.formatyear(startyear, m = 4)
+doc.insertPage(-1, txt, fontsize = 12, fontname = "Courier", width = w, height = h)
 
-txt = cal.formatyear(startyear + 1, m = 4, c = 10)
-doc.insertPage(-1, txt, fontname = "Courier", width = 842, height = 595)
+txt = cal.formatyear(startyear + 1, m = 4)
+doc.insertPage(-1, txt, fontsize = 12, fontname = "Courier", width = w, height = h)
 
-txt = cal.formatyear(startyear + 2, m = 4, c = 10)
-doc.insertPage(-1, txt, fontname = "Courier", width = 842, height = 595)
+txt = cal.formatyear(startyear + 2, m = 4)
+doc.insertPage(-1, txt, fontsize = 12, fontname = "Courier", width = w, height = h)
 
-doc.save("calendar.pdf", garbage = 4, deflate = True)
+doc.save("Kalender.pdf", garbage = 4, deflate = True)

History