Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6569949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:41:41+00:00 2026-05-25T14:41:41+00:00

How can I produce a printable PDF file (US letter sized) such that each

  • 0

How can I produce a printable PDF file (US letter sized) such that each page represents a month and is partitioned such that each day of the month gets a box of equal size? What if I want to skip weekends and just display weekdays?

What Python modules would I use to accomplish the following?:

  1. Producing an image with the resolution of a US letter
  2. Iterating through each day of the month with the option to skip specific days (e.g., all weekends)
  3. Partitioning the image such that each day of the month is listed in a box of fixed size
  4. Repeating steps 2-3 for all months in a given year
  5. Producing a pdf as the output
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:41:42+00:00Added an answer on May 25, 2026 at 2:41 pm

    You could do it with 3 packages. ‘Reportlab’ for producing the pdf, ‘calendar’ for getting the month as lists of lists, and python binding for ‘Ghostscript’ to transform the pdf produced into a png.

    You would start by getting the data from the calendar package, using Reportlab to produce a page of US letter size. The table can be manipulated to have a grid, have each cell a box of the same size and alter the text font, size, and alignment.

    You could leave it at that if you just want a pdf, or you can convert this pdf into a image using Ghostscript python bindings. Or if you like you can just run ‘Ghostscript’ using system(‘gs …’). Also Ghostscript must be installed for the python ‘Ghostscript’ package to work.

    If you want to filter out all weekends then you can use good old fashioned list manipulation on the calendar data for that.

    Here is a example of how you could produce the pdf. I’m not going to do a whole year just a single month, and I’m not going to bother filtering out the zeros.

    from reportlab.lib.units import inch
    from reportlab.lib import colors
    from reportlab.lib.pagesizes import letter
    from reportlab.platypus import SimpleDocTemplate, Table, TableStyle
    from reportlab.graphics.shapes import Drawing
    
    import calendar
    
    doc = SimpleDocTemplate('calendar.pdf', pagesize=letter)
    
    cal = [['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']]
    cal.extend(calendar.monthcalendar(2011,9))
    
    
    table = Table(cal, 7*[inch], len(cal) * [inch])
    
    table.setStyle(TableStyle([
            ('FONT', (0, 0), (-1, -1), 'Helvetica'),
            ('FONT', (0, 0), (-1, 0), 'Helvetica-Bold'),
            ('FONTSIZE', (0, 0), (-1, -1), 8),
            ('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
            ('BOX', (0, 0), (-1, -1), 0.25, colors.green),
            ('ALIGN', (0, 0), (-1, -1), 'CENTER'),
            ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
        ]))
    
    #create the pdf with this
    doc.build([table])
    

    If you want another page add PageBreak() followed by the next calendar to the list passed to doc.build(). PageBreak is part of reportlab.platypus.

    And to convert the pdf to png

    import ghostscript
    
    args = ['gs', #it seems not to matter what is put in 1st position
            '-dSAFER',
            '-dBATCH',
            '-dNOPAUSE',
            '-sDEVICE=png16m',
            '-r100',
            '-sOutputFile=calendar.png',
            'calendar.pdf']
    
    ghostscript.Ghostscript(*args)
    

    Both reportlab and ghostscript packages are available through the use of pip. I created the above in a ‘virtualenv’ environment.

    ReportLab
    http://www.reportlab.com/software/opensource/rl-toolkit/

    Ghostscript python bindings
    https://bitbucket.org/htgoebel/python-ghostscript

    calendar is part of the standard python library.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any library that can produce server-side pie charts using Ruby? Such as
Is there a tool available that can produce an HTML summary list of perl
I'm writing a small .NET application that can produce SWF files, and I need
In native development, you can produce libraries - .so, .dll etc - that other
I have a series of .NET WCF RESTFul services that can produce either JSON
How can I produce a messagebox in a C# Win Forms application that displays
This is a pretty esoteric issue that I can't produce a small test case
Is there software that can produce a searchable database with the following information: Names
The PDF I can produce at the moment: (source: yart.com.au ) I want the
Simplest explanation I can produce: In my .NET1.1 web app I create a file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.