Spaces:
Running
Running
|
Download README.md from sisithefox/sisi-pdf-api: direct link, hf CLI and curl.
- Browser
- Download file 3.95 kB
-
https://huggingface.co/spaces/sisithefox/sisi-pdf-api/resolve/main/README.md
- Command line
-
hf download hf://spaces/sisithefox/sisi-pdf-api/README.md
-
curl -L -o README.md https://huggingface.co/spaces/sisithefox/sisi-pdf-api/resolve/main/README.md
3.95 kB
metadata
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:
{
"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 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:
{
"success": true,
"filename": "document.pdf",
"pdf_base64": "JVBERi0xLjcK...",
"size_bytes": 123456
}
๐จ Example Usage
JavaScript/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
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