Skip to content

Tombola card pdf generator from html format template

Notifications You must be signed in to change notification settings

mc-cat-tty/TombolaCardPDF

Repository files navigation

TombolaCardPDF

Tombola card pdf generator from html format template

Results

Result Card

Setting up

pip3 install jinja2
pip3 install pdfkit
pip3 install PyPDF2
sudo apt install wkhtmltopdf

or

pip3 install -r requirements.txt

Run the script

cat cards_set.txt > python3 pdf_formatter.py

OR

Pipe generator output directly into pdf_formatter

python3 generator.py | python3 pdf_formatter.py -b "place your bottom text here"

generator.py arguments

-n Number of card sets. Default value is 1

pdf_formatter.py Arguments

-b Bottom text

-l Logo filename

-t Template (HTML) filename

-o Output PDF filename

Genrate multiple card sets

Results

This command will generate 5 card sets:

python3 generator.py -n 5 | python3 pdf_formatter.py -b "place your bottom text here" -l logo.jpeg

All the sets will be merged into a single pdf file

Bottom text on multiple lines

python3 pdf_formatter.py -b "First line <br> second line <br> third line"

Divide multiple lines with "<br>" HTML tag

cards_set.txt sample

Input must be formatted in the following way: cards_set.txt sample

Formatting rules:

  • there must be two lines for each card:
    • the first one is the name of that card inside the set
    • the second one is a Python list containing one list of integers for each row (of that card)
  • everything after the last pair of lines will be discarded (odd line)
  • blank fileds placeholder is -1