Generate printable PDF files for tabletop RPG tokens
Project description
Here’s a revised approach for a "Getting Started" manual in readme.md, structured to guide users step-by-step from simple to advanced usage:
TokenPDF: Generate Printable RPG Tokens with Ease
TokenPDF is a lightweight Python library for creating printable PDF files containing RPG tokens. It simplifies the process of generating tokens for monsters, characters, and other entities in tabletop role-playing games (specifically Dungeons & Dragons and similar games).
Example of generated tokens.
Getting Started
Installation
TokenPDF will soon be available on PyPI. For now, clone the repository and install its dependencies:
git clone https://github.com/Dormat2/tokenpdf.git
cd tokenpdf
pip install -r requirements.txt
Command-Line Interface
The library provides a simple command-line tool:
python -m tokenpdf <config_files> [-o OUTPUT] [-v] [-s]
config_files: One or more configuration files in TOML, JSON, YAML, or INI format. If omitted,example.tomlis used.-o OUTPUT: The output PDF file (default:output.pdf).-v: Enable verbose output.-s: Silence most output.
Example usage:
python -m tokenpdf example.toml -o my_tokens.pdf -v
Writing Configuration Files
Configurations define your tokens, page settings, and more. Let's start with a simple example.
Minimal Configuration: Single Token
TOML Example
output = "single_token.pdf"
[monsters.circle_token]
name = "Circle Token"
size = "Medium"
image_url = "https://picsum.photos/200"
tokens = [
{ type = "circle", size = "medium", count = 1 }
]
JSON Example
{
"output": "single_token.pdf",
"monsters": {
"circle_token": {
"name": "Circle Token",
"size": "Medium",
"image_url": "https://picsum.photos/200",
"tokens": [
{ "type": "circle", "size": "medium", "count": 1 }
]
}
}
}
Adding Features Step-by-Step
1. Adding Multiple Tokens
Add multiple tokens for the same monster:
TOML Example
[monsters.circle_token]
name = "Circle Token"
size = "Medium"
image_url = "https://picsum.photos/200"
tokens = [
{ type = "circle", size = "medium", count = 5 }
]
JSON Example
{
"monsters": {
"circle_token": {
"name": "Circle Token",
"size": "Medium",
"image_url": "https://picsum.photos/200",
"tokens": [
{ "type": "circle", "size": "medium", "count": 5 }
]
}
}
}
2. Customizing Token Appearance
Add margins and scaling to tokens:
TOML Example
[monsters.circle_token]
name = "Circle Token"
size = "Medium"
image_url = "https://picsum.photos/200"
tokens = [
{ type = "circle", size = "medium", count = 5, scale = 1.1, scale_rho = 0.1 }
]
JSON Example
{
"monsters": {
"circle_token": {
"name": "Circle Token",
"size": "Medium",
"image_url": "https://picsum.photos/200",
"tokens": [
{ "type": "circle", "size": "medium", "count": 5, "scale": 1.1, "scale_rho": 0.1 }
]
}
}
}
Global Settings
Customize the entire output, page, and layout behavior. Here’s how to configure global settings.
1. Output File
Specify the name of the PDF file:
TOML
output = "my_custom_tokens.pdf"
JSON
{
"output": "my_custom_tokens.pdf"
}
2. Page Settings
Define the paper size, orientation, and margins:
TOML
page_size = "A4"
orientation = "portrait"
margin = 0.05
JSON
{
"page_size": "A4",
"orientation": "portrait",
"margin": 0.05
}
3. Layout Options
Enable token rotation for better page utilization:
TOML
rotation = true
JSON
{
"rotation": true
}
Advanced Examples
Mixed Token Types
TOML
[monsters.goblins]
name = "Goblins"
size = "Small"
image_url = "https://picsum.photos/300"
tokens = [
{ type = "circle", size = "small", count = 10 },
{ type = "standing", size = "small", count = 5 }
]
JSON
{
"monsters": {
"goblins": {
"name": "Goblins",
"size": "Small",
"image_url": "https://picsum.photos/300",
"tokens": [
{ "type": "circle", "size": "small", "count": 10 },
{ "type": "standing", "size": "small", "count": 5 }
]
}
}
}
Screenshots
-
Example configuration:
-
Generated PDF:
Contributing
Contributions are welcome! Feel free to submit issues or pull requests via GitHub.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tokenpdf-0.1.0.tar.gz.
File metadata
- Download URL: tokenpdf-0.1.0.tar.gz
- Upload date:
- Size: 26.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
515eeba30e8cb5801c1ad84205e92e8ebf6d692833d7305363ae99885738931a
|
|
| MD5 |
084e8c9171dd2f05e7f04d315a1d764a
|
|
| BLAKE2b-256 |
7316f430db5d42640dba90b56c61a6d998446cb5c0e4ac3b17115e1eaf55e382
|
File details
Details for the file tokenpdf-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tokenpdf-0.1.0-py3-none-any.whl
- Upload date:
- Size: 31.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfb82f6088a6d62a88cee6ec15d8490685fa9bafaec32fdb155b60927747b9c6
|
|
| MD5 |
f61ea71eb506cb231693ab24e7589d85
|
|
| BLAKE2b-256 |
b61e11dbcffa70dcbdf32467ecd3ec65e6d945a38025899e2101cc91343a8b7a
|