Spaces:
Running
Running
File size: 3,954 Bytes
4d9617f e72cddb bebd683 e72cddb bebd683 e72cddb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | ---
title: Sisi PDF API
emoji: ๐ฆ
colorFrom: purple
colorTo: pink
sdk: docker
pinned: false
app_port: 7860
---
# ๐ฆ Sisi PDF API
Universal HTML to PDF converter with **perfect** support for:
- โ
Chinese (Simplified & Traditional): ็ฎไฝไธญๆใ็น้ซไธญๆ
- โ
Colorful Emoji: ๐ฆ๐โจ๐โญ๐
- โ
SVG Graphics: 100% accurate rendering
- โ
Modern CSS3: Flexbox, Grid, Gradients, Shadows
- โ
All Unicode symbols: โโโโโโโโโโโโ
## ๐ Features
- **Powered by Playwright + Chromium**: Industry-leading rendering engine
- **Zero client-side dependencies**: Everything runs on the server
- **Async/concurrent**: Handle multiple requests simultaneously
- **Production-ready**: Used by Sisi Astrology, Astrology Bazi, and more
## ๐ API Endpoints
### `POST /generate-pdf`
Generate PDF from HTML and return as binary file.
**Request Body**:
```json
{
"html_content": "<html>...</html>",
"filename": "document.pdf",
"page_size": "A4",
"margin_top": "20mm",
"margin_bottom": "20mm",
"margin_left": "20mm",
"margin_right": "20mm",
"print_background": true,
"landscape": false,
"prefer_css_page_size": false,
"render_timeout_ms": 30000
}
```
For branded multi-page reports, set all API margins to `0`, enable
`prefer_css_page_size`, and define page margins in the HTML `@page` CSS.
## Branded report integration
See [docs/branded-report-pdf-playbook.md](docs/branded-report-pdf-playbook.md)
for the reusable Astrology Bazi workflow: deterministic HTML templates,
Cloudflare server-side proxying, embedded logos, full-bleed covers, pagination,
and visual PDF verification.
**Response**: PDF binary file
### `POST /generate-pdf-base64`
Generate PDF and return as base64 string (useful for JSON APIs).
**Response**:
```json
{
"success": true,
"filename": "document.pdf",
"pdf_base64": "JVBERi0xLjcK...",
"size_bytes": 123456
}
```
## ๐จ Example Usage
### JavaScript/TypeScript
```typescript
const response = await fetch('https://sisithefox-pdf-api.hf.space/generate-pdf', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
html_content: `
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
body { font-family: 'Noto Sans CJK', Arial; }
h1 { color: purple; }
</style>
</head>
<body>
<h1>๐ฆ ๅฐ้ฑผ็ๆ็ๆฅๅ</h1>
<p>็ฎไฝไธญๆใ็น้ซไธญๆใEmoji ๐</p>
<svg>...</svg>
</body>
</html>
`,
filename: 'natal-chart.pdf'
})
})
const blob = await response.blob()
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = 'natal-chart.pdf'
a.click()
```
### Python
```python
import requests
response = requests.post(
'https://sisithefox-pdf-api.hf.space/generate-pdf',
json={
'html_content': '<html>...</html>',
'filename': 'document.pdf'
}
)
with open('output.pdf', 'wb') as f:
f.write(response.content)
```
## ๐ Perfect for
- ๐ Birth Chart Reports (Sisi Astrology)
- ๐ฎ Bazi Fortune Readings (Astrology Bazi)
- ๐ Healing Reports (SisiTheFox)
- ๐ Invoices, Receipts, Certificates
- ๐ Any document with Chinese/Emoji/SVG
## ๐๏ธ Deployment
This API is deployed on **Hugging Face Spaces** (free tier):
- URL: `https://sisithefox-pdf-api.hf.space`
- RAM: 16GB (more than enough)
- Storage: 50GB
- Uptime: 99.9% (with UptimeRobot monitoring)
## ๐ฐ Cost
**$0** - Completely free thanks to Hugging Face Spaces!
## ๐ Security
- CORS enabled for all origins (public API)
- No data stored - PDFs generated on-the-fly
- Stateless architecture
## ๐ Performance
- Generation time: 2-5 seconds per PDF
- Concurrent requests: 5-10 simultaneous
- Max PDF size: ~50MB (more than enough for reports)
---
๐ฆ Made with love by Sisi for Sparksverse ecosystem
|