How the PDF to EPUB Converter Works
AnyTool PDF to EPUB reads a PDF entirely in the browser with pdf.js, whose worker is bundled into the app and served from the same origin — never loaded from a CDN — so the tool stays fully offline-capable and uploads nothing. A PDF stores no semantic document model, only positioned glyphs, so for each page the converter calls getTextContent() to obtain every text run with its position, font size and width, groups runs that share a baseline into lines, inserts spaces from x-gaps pdf.js omitted, and reconstructs the page. The document’s median font size is taken as the body text, and lines whose size is meaningfully larger are flagged as headings; soft-wrapped lines are merged into flowing paragraphs and hyphenated words are rejoined. The structured blocks are split into chapters — by detected top-level heading, every N pages, or as a single document — and each chapter is rendered as a fully XML-escaped XHTML file. JSZip then assembles a spec-valid EPUB 3: the mimetype entry (“application/epub+zip”) is written first and stored uncompressed as the spec requires, followed by META-INF/container.xml, an OEBPS/content.opf package document with dc:title, dc:creator, dc:language, a freshly generated UUID identifier and a dcterms:modified timestamp, an EPUB 3 nav.xhtml and an EPUB 2 toc.ncx fallback, a reflowable style.css, and one XHTML file per chapter.
- Text read with pdf.js getTextContent() — position, font size, width
- pdf.js worker bundled locally (pdf.worker.min.mjs?url) — no CDN
- EPUB assembled with JSZip; mimetype written first and stored uncompressed
- content.opf carries title, author, language and a generated UUID
- nav.xhtml (EPUB 3) and toc.ncx (EPUB 2) built from chapter titles
