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)
Metadata
Release files for pyshapdf 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyshapdf-0.2.1.tar.gz | 89.7 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyshapdf-0.2.1-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details |
| pyshapdf-0.2.1-cp312-cp312-manylinux_2_34_x86_64.whl | CPython 3.12 | CPython 3.12 | Linux glibc 2.34+ x86-64 | Details |
| pyshapdf-0.2.1-cp312-cp312-macosx_11_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 11.0+ ARM64 | Details |
Total release size: 856.2 kB
Release files / pyshapdf-0.2.1.tar.gz
| Download URL | pyshapdf-0.2.1.tar.gz |
|---|---|
| Size | 89.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5bb7c9f9dd20243738162600a240383e109be9fdc3ef6c040d0f1e6b9940dd1b
|
|
BLAKE2b-256 checksum How to use checksums |
18377bcda1fc8fbd18774f516c55c02514ceeeadecbc298f985eaaac07c09d10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 13, 2025.
Transparency logRelease files / pyshapdf-0.2.1-cp312-cp312-win_amd64.whl
| Download URL | pyshapdf-0.2.1-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 175.7 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
083dbd14081fad52bcd369efe81c9de617277577e37caf97b946a306b0913894
|
|
BLAKE2b-256 checksum How to use checksums |
7abaccb72cb4ed5eac8ec5fd94dac6fe1667706c80427b6f984949560a693934
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 13, 2025.
Transparency logRelease files / pyshapdf-0.2.1-cp312-cp312-manylinux_2_34_x86_64.whl
| Download URL | pyshapdf-0.2.1-cp312-cp312-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 316.1 kB |
| Tags | CPython 3.12 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
e6db5bdc0b48cefd622a4b77bf89f2cd89811caa501bc64ba6d354f1258ff8ab
|
|
BLAKE2b-256 checksum How to use checksums |
8b8c83f208dfaafe2b4dc15ab2464d6fbad49d2df79282b539397a807127d732
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 13, 2025.
Transparency logRelease files / pyshapdf-0.2.1-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | pyshapdf-0.2.1-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 274.7 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
9acd7aebeb42fe74fbade2ab43c3a9f70ce76b8cdecfc790be10409ff1765911
|
|
BLAKE2b-256 checksum How to use checksums |
ea218e3b37f598c3e151ea4a912cd4fc18ce9dc0ce029bdf535f9c37a2ac80a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 13, 2025.
Transparency log