This Python script generates a PDF of flashcards from a list of sentences stored in a text file. It utilizes the ReportLab library to generate the cards in a grid format on A4 paper, each card containing a sentence with customizable formatting. Sentences can include basic formatting such as bold and italics using simple BBCode-like tags.
- Automatically lays out sentences into 2 columns and 6 rows per page.
- Supports bold and italic text using
[b]
and[i]
BBCode tags. - Customizable card sizes and margins.
- Creates a PDF output with all cards evenly distributed across pages.
You need reportlab
for generating PDFs
pip install reportlab
The input to the script is a plain text file (sentence_list.txt
) where each line represents a sentence that will be placed on a separate card. Example from sentence_list:
[b]Show, don't tell[/b]: Let readers experience the story through actions, dialogue, and senses rather than exposition.
[b]Create compelling characters[/b]: Characters should have clear goals, motivations, and obstacles that drive the story forward.
The script generates a PDF file (output_cards.pdf
) with flashcards arranged in a 2x6 grid on each page. Each card will display one sentence from the input file.
To generate the flashcards, place the python script in same directory as sentence_list.txt and run from there from powershell/cmd.
python pyflashcards.py
If you want to use different input or output file names, modify the call to create_cards
at the bottom of the script:
create_cards('your_input_file.txt', 'your_output_file.pdf')