This script generates resistor labels as images and compiles them into a printable PDF. It allows customization of label dimensions, fonts, page sizes, and resistor values. Currently it will generate a set of labels to fit my print profile found here
This process is easiest if all steps are done in the terminal.
-
Install Python (if not installed)
- Download and install Python from https://www.python.org/
-
Create a Directory for the Script
mkdir -p ~/Downloads/resistor_labels cd ~/Downloads/resistor_labels
-
Download or Copy the Script
- Save this script as
resistor_labels.py
inside theresistor_labels
folder.
- Save this script as
-
Set Up a Virtual Environment
python3 -m venv venv
-
Activate the Virtual Environment
source venv/bin/activate # On macOS/Linux venv/Scripts/activate # On Windows (Command Prompt) (may need to swap to backslashes)
-
Install Dependencies
pip install Pillow reportlab
-
Ensure a Valid Font File is Available
- The script requires a TrueType font file (TTF). If
Arial.ttf
is missing, either:- Place an
Arial.ttf
file in the script directory. - Change
FONT_PATH
in the script to another available font (e.g.,/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf
).
- Place an
- The script requires a TrueType font file (TTF). If
-
Run the Script
python resistor_labels.py
- This will generate resistor label images in the
labels/
folder and createlabels.pdf
containing all labels arranged for printing.
- This will generate resistor label images in the
Modify the values in the script under each section to change label dimensions, page size, font, etc. """