EPUB → PDF
Convert .epub files to PDF. Works for Chinese/Japanese/Korean text.
Prerequisites
apt-get install -y weasyprint
pip3 install --break-system-packages ebooklib beautifulsoup4 lxml
CJK fonts required:
/root/.openclaw/workspace/skills/pdf-maker/NotoSansCJKsc.ttf/root/.openclaw/workspace/skills/pdf-maker/NotoSansCJKscB.ttf
Usage
python3 scripts/epub2pdf.py <input.epub> <output.pdf>
How it works
ebooklibreads allITEM_DOCUMENTentries from the EPUBBeautifulSoup + lxmlstrips<script>,<style>,<link>,<meta>tags- Injects CJK fonts via
@font-faceCSS WeasyPrintrenders combined HTML to A4 PDF (2cm margins, justified)
Troubleshooting
| Symptom | Fix |
|---|---|
| WeasyPrint import fails | apt-get install weasyprint |
| CJK characters garbled | Ensure font TTF path is correct (TTC collections won't work) |
| Empty / tiny PDF | EPUB has no readable document entries — check TNC count |
| calibre root sandbox error | Don't use calibre; use this script instead |
