Python bindings for shapdf - Create Shapes into PDF
Project description
pyshapdf
Python bindings for shapdf - Create Shapes into PDF
Efficient programmable generation of shapes in PDF using Rust and Python.
Installation
pip install pyshapdf
Quick Start
import pyshapdf
script = """
page letter
circle 100mm 150mm 20mm color=blue
rectangle 50mm 50mm 40mm 30mm color=green angle=45deg anchor=center
line 50mm 200mm 150mm 250mm width=2mm color=red cap=round
"""
pyshapdf.render_script(script, "output.pdf")
Script Syntax
The .shapdf script language supports:
Page Commands
page default # Default page size
page letter # US Letter (8.5" × 11")
page letter-landscape # US Letter landscape
page a4 # A4 (210mm × 297mm)
page a4-landscape # A4 landscape
page size 200mm 300mm # Custom size
Shape Commands
# Circle
circle <x> <y> <radius> [color=...]
# Rectangle
rectangle <x> <y> <width> <height> [color=...] [anchor=...] [angle=...]
# Line
line <x1> <y1> <x2> <y2> [width=...] [color=...] [cap=...]
Settings
set default_page_size 200mm 300mm
set default_width 2mm
set default_color blue
set default_cap round # butt | round | square
set default_angle 45deg # or 0.785rad
Units
mm- millimeterscm- centimetersin- inchespt- points (1/72 inch)deg- degrees (default for angles)rad- radians
Colors
- Named colors:
red,green,blue,yellow,black,white,gray - Hex:
#RRGGBB(e.g.,#ff0000) - RGB:
rgb(255, 0, 0) - Grayscale:
gray(0.5)
Anchor Points (for rectangles)
bottomleft(default)centertopleft,topright,bottomrightmidleft,midright,midbottom,midtop
API Reference
render_script(script: str, output_path: str) -> None
Render a .shapdf script to a PDF file.
Parameters:
script(str): The.shapdfscript contentoutput_path(str): Path to write the output PDF file
Raises:
RuntimeError: If PDF generation fails
Examples
Multi-page Document
import pyshapdf
script = """
# Page 1 - Circles
page letter
circle 100mm 150mm 30mm color=blue
circle 150mm 150mm 30mm color=red
# Page 2 - Rectangles
page a4
rectangle 105mm 148.5mm 50mm 40mm color=green anchor=center angle=30deg
"""
pyshapdf.render_script(script, "multi_page.pdf")
Technical Drawing
import pyshapdf
script = """
page size 200mm 150mm
set default_width 0.5mm
set default_color black
# Grid lines
line 20mm 20mm 180mm 20mm
line 20mm 50mm 180mm 50mm
line 20mm 80mm 180mm 80mm
line 20mm 110mm 180mm 110mm
line 20mm 20mm 20mm 110mm
line 50mm 20mm 50mm 110mm
line 100mm 20mm 100mm 110mm
line 150mm 20mm 150mm 110mm
line 180mm 20mm 180mm 110mm
# Highlight
circle 100mm 65mm 2mm color=red
rectangle 85mm 50mm 30mm 30mm color=#0066ff anchor=center angle=0deg
"""
pyshapdf.render_script(script, "technical.pdf")
Links
- 🌐 Try it online: shapdf.wqzhao.org
- 📚 Rust Documentation: docs.rs/shapdf
- 💻 Source Code: github.com/Teddy-van-Jerry/shapdf
- 🐛 Report Issues: GitHub Issues
License
GPL-3.0-or-later
© 2025 Teddy van Jerry (Wuqiong Zhao)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
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 pyshapdf-0.2.1.tar.gz.
File metadata
- Download URL: pyshapdf-0.2.1.tar.gz
- Upload date:
- Size: 89.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bb7c9f9dd20243738162600a240383e109be9fdc3ef6c040d0f1e6b9940dd1b
|
|
| MD5 |
46277f48dd72b32b244fff475afee508
|
|
| BLAKE2b-256 |
18377bcda1fc8fbd18774f516c55c02514ceeeadecbc298f985eaaac07c09d10
|
Provenance
The following attestation bundles were made for pyshapdf-0.2.1.tar.gz:
Publisher:
python-publish.yml on Teddy-van-Jerry/shapdf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyshapdf-0.2.1.tar.gz -
Subject digest:
5bb7c9f9dd20243738162600a240383e109be9fdc3ef6c040d0f1e6b9940dd1b - Sigstore transparency entry: 699217156
- Sigstore integration time:
-
Permalink:
Teddy-van-Jerry/shapdf@08668046e1c4d7ddc217bd3e4f44fbc675145240 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/Teddy-van-Jerry
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@08668046e1c4d7ddc217bd3e4f44fbc675145240 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyshapdf-0.2.1-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: pyshapdf-0.2.1-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 175.7 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
083dbd14081fad52bcd369efe81c9de617277577e37caf97b946a306b0913894
|
|
| MD5 |
147a8304acfd90de7d49637b214907b9
|
|
| BLAKE2b-256 |
7abaccb72cb4ed5eac8ec5fd94dac6fe1667706c80427b6f984949560a693934
|
Provenance
The following attestation bundles were made for pyshapdf-0.2.1-cp312-cp312-win_amd64.whl:
Publisher:
python-publish.yml on Teddy-van-Jerry/shapdf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyshapdf-0.2.1-cp312-cp312-win_amd64.whl -
Subject digest:
083dbd14081fad52bcd369efe81c9de617277577e37caf97b946a306b0913894 - Sigstore transparency entry: 699217164
- Sigstore integration time:
-
Permalink:
Teddy-van-Jerry/shapdf@08668046e1c4d7ddc217bd3e4f44fbc675145240 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/Teddy-van-Jerry
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@08668046e1c4d7ddc217bd3e4f44fbc675145240 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyshapdf-0.2.1-cp312-cp312-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: pyshapdf-0.2.1-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 316.1 kB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6db5bdc0b48cefd622a4b77bf89f2cd89811caa501bc64ba6d354f1258ff8ab
|
|
| MD5 |
19590d37df67d81b038c33a80d0d8b36
|
|
| BLAKE2b-256 |
8b8c83f208dfaafe2b4dc15ab2464d6fbad49d2df79282b539397a807127d732
|
Provenance
The following attestation bundles were made for pyshapdf-0.2.1-cp312-cp312-manylinux_2_34_x86_64.whl:
Publisher:
python-publish.yml on Teddy-van-Jerry/shapdf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyshapdf-0.2.1-cp312-cp312-manylinux_2_34_x86_64.whl -
Subject digest:
e6db5bdc0b48cefd622a4b77bf89f2cd89811caa501bc64ba6d354f1258ff8ab - Sigstore transparency entry: 699217160
- Sigstore integration time:
-
Permalink:
Teddy-van-Jerry/shapdf@08668046e1c4d7ddc217bd3e4f44fbc675145240 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/Teddy-van-Jerry
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@08668046e1c4d7ddc217bd3e4f44fbc675145240 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyshapdf-0.2.1-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyshapdf-0.2.1-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 274.7 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9acd7aebeb42fe74fbade2ab43c3a9f70ce76b8cdecfc790be10409ff1765911
|
|
| MD5 |
f6e6f430fda8fdce5517ffa2e422592b
|
|
| BLAKE2b-256 |
ea218e3b37f598c3e151ea4a912cd4fc18ce9dc0ce029bdf535f9c37a2ac80a0
|
Provenance
The following attestation bundles were made for pyshapdf-0.2.1-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
python-publish.yml on Teddy-van-Jerry/shapdf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyshapdf-0.2.1-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
9acd7aebeb42fe74fbade2ab43c3a9f70ce76b8cdecfc790be10409ff1765911 - Sigstore transparency entry: 699217167
- Sigstore integration time:
-
Permalink:
Teddy-van-Jerry/shapdf@08668046e1c4d7ddc217bd3e4f44fbc675145240 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/Teddy-van-Jerry
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@08668046e1c4d7ddc217bd3e4f44fbc675145240 -
Trigger Event:
push
-
Statement type: