Open In App

Visual TimeTable using pdfschedule in Python

Last Updated : 06 Jun, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

Scheduling is the greater part of life and having a timetable helps in setting up a routine. Boring timetables or routines made just in mind don’t usually help. Having a flashy and visually appealing timetable attracts and hence pushes us to look and follow. This article presents an easy way to produce one in pdf format for each day in the week and follows it using Python.

pdfschedule: This module is able to create PDF format timetables for the weekly schedule of events and supports custom styling and colors, operated using Command-Line.

Installation 

This module does not come built-in with Python. To install it type the below command in the terminal.

python3 -m pip install pdfschedule

Getting Started

After the installation, run the following command on the command line:

pdfschedule [<OPTIONS>] [<infile> [<outfile>]]

Parameter:

  • infile : The standard input file (yaml format).
  • outfile : Output file in pdf format with the same name as the input file. <infile>.pdf.
  • OPTIONS : Styling parameters that can be passed.

Options : 

  • -C, –color : Event boxes colors, Standard hex codes to be used.
  • -F <font>, –font <font> : Any builtin font or path to .ttf file. Defaults to Helvetica.
  • -f <size>, –font-size <size> : Event name font size. Sets name of week to <size> * 1.2 and name of times to <size> / 1.2. Defaults to 10.
  • -M, –start-monday :  Typing this will render start of week to Monday, otherwise, its Sunday.
  • -p, –portrait : Sets the output table to portrait mode, which by default is landscape mode.
  • -s <factor>, –scale <factor> : Shorted the sides of tables by “/factor” . Otherwise, the table takes whole page, baring margins
  • -T, –no-times : Ignores time not in use.
  • –no-weekends : Removed weekends, Sunday and Saturday from table.

Input File

Yaml: The required Yaml is a list of dictionaries, where each dictionary represents each slot in a schedule, with its display description.

Input Parameters in Yaml [ for each schedule ]

  • name: Name of the event in box. Optional.
  • days: Days to repeat the said schedule. Initial letter capital and 1st two/ Three initials of each weekday are valid. Single letter weekday representation valid in case of Monday, Tuesday, Wednesday, Friday. 
  • time: Time of Schedule, “HH:MM – HH:MM” 24 hour format. Minutes Optional.
  • color: Background color for schedule (provided in hex), defaults to Grey.

Example:

Input file : [ gfg_tt.yml ]

- name: Morning Walk
 days: MWF
 time: 7-9
 color: "0000FF"

- name: Ofc Hours
 days: MTWThF
 time: 10-19

- name: Exercise
 days: M, W, F
 time: 19:30 - 20:30
 color: "29EE65"

- name: Play Cricket
 days: Tu, Th, Sat
 time: 19:30 - 20:30
 color: "FF94EF"

- name: Surf GFG
 days: F, W, M
 time: 22-23.59
 color: "000000"

- name: Sleep Time
 days: MTWThFSatSun
 time: 0-7
 color: "00FF00"

After this, run this command on the command line:

pdfschedule gfg_tt

Output : 


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads