tikzify
v0.0.42
Published
Generate beautiful PDF books with emoji SVG overlays and custom backgrounds using XeLaTeX and TikZ.
Readme
tikzsvg
Generate beautiful PDF books with emoji SVG overlays and custom backgrounds using XeLaTeX and TikZ.
Features
- 📚 Create multi-page PDF books from JSON input
- 🎨 Gradient backgrounds with customizable colors
- 🖼️ Embed images with custom shaped clipping paths
- ✨ SVG emoji overlays with precise positioning, scaling, and rotation
- 🌐 RTL (right-to-left) and LTR (left-to-right) text support
- 🔤 Hebrew text support with Fredoka-Bold font
- 📄 A5 paper format with page numbering
Prerequisites
- Bun runtime
- XeLaTeX (from TeX Live or similar distribution)
Fredoka-Bold.ttffont file in the project root
Installation
bun installUsage
Server Mode
Start the HTTP server:
bun --hot src/server.tsSend a POST request with JSON book data:
curl http://localhost:3000/ \
-H "Content-Type: application/json" \
-d @book.json \
-o output.pdfBook JSON Format
{
"dir": "rtl",
"pages": [
{
"gradient": ["#8B4513", "#FFD1E0"],
"textBg": "#FFF3E6",
"text": [
"Line 1 of text",
"Line 2 of text"
],
"emojis": {
"text": [
{
"x": 10,
"y": 20,
"scale": 1.8,
"rotate": -15,
"emoji": "🍄"
}
],
"image": [
{
"x": -170,
"y": -130,
"scale": 1.8,
"rotate": -15,
"emoji": "🌺"
}
]
},
"jpgBase64": "base64-encoded-image-data"
}
]
}API Reference
Book Schema
dir: Text direction ("rtl"or"ltr")pages: Array of page objects
Page Schema
gradient: Array of two hex colors for background gradienttextBg: Hex color for text background overlaytext: Array of text lines to displayemojis.text: Emoji overlays for text pagesemojis.image: Emoji overlays for image pagesjpgBase64: Base64-encoded JPEG image (max 256KB)
Emoji Schema
x,y: Position coordinates in pointsscale: Scale factorrotate: Rotation angle in degreesemoji: Unicode emoji character
How It Works
- Receives book JSON via HTTP POST
- Parses and validates input using Zod schemas
- Converts emoji to SVG paths using pre-defined emoji map
- Generates XeLaTeX document with TikZ graphics
- Runs XeLaTeX twice to resolve coordinate references
- Returns compiled PDF
Development
The project uses:
- Bun for runtime and package management
- TypeScript for type safety
- Zod for schema validation
- SAX for SVG parsing
- p-queue for sequential PDF generation
License
MIT
