EPUB是电子出版物的一种开放标准格式。它是由国际数字出版论坛(IDPF)开发的,并在2007年首次发布。 EPUB文件可以包含文本、图像、样式表和元数据等内容,并与可读取的设备无关。这意味着无论使用哪种操作系统或设备,用户都可以使用相同的应用程序来打开和阅读EPUB文件。此外,EPUB支持文字重新排列、字体大小调整、屏幕旋转等功能,使得用户可以自定义阅读体验。
epub 实质上是一个 zip 归档文件,把它解压就能看到其实质。最基础最简单的 epub 文件如下所示
EPUB.epub ├── META-INF │ └── container.xml ├── mimetype └── OEBPS ├── content.opf ├── toc.ncx ├── Images │ └── cover.jpg └── Text ├── cover.xhtml ├── summary.xhtml ├── 001.xhtml ├── ... └── 003.xhtml
详解,打 √ 的不用修改
META-INF/container.xml
xml<?xml version="1.0" encoding="UTF-8"?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
mimetype
xmlapplication/epub+zip
OEBPS/content.opf
以下可以乱填
xml<?xml version="1.0" encoding="utf-8"?>
<package version="2.0" unique-identifier="BookId" xmlns="http://www.idpf.org/2007/opf">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
<dc:language>zh</dc:language>
<dc:title>书名</dc:title>
<dc:creator opf:role="aut">作者</dc:creator>
<dc:date opf:event="modification" xmlns:opf="http://www.idpf.org/2007/opf">年-月-日</dc:date>
<dc:identifier opf:scheme="UUID" id="BookId">urn:uuid:通用唯一识别码</dc:identifier>
<meta name="cover" content="cover.jpg"/>
</metadata>
<manifest>
<item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/>
<item id="cover.jpg" href="Images/cover.jpg" media-type="image/jpeg"/>
<item id="x001.xhtml" href="Text/001.xhtml" media-type="application/xhtml+xml"/>
<item id="x002.xhtml" href="Text/002.xhtml" media-type="application/xhtml+xml"/>
<item id="x003.xhtml" href="Text/003.xhtml" media-type="application/xhtml+xml"/>
<item id="cover.xhtml" href="Text/cover.xhtml" media-type="application/xhtml+xml"/>
<item id="summary.xhtml" href="Text/summary.xhtml" media-type="application/xhtml+xml"/>
</manifest>
<spine toc="ncx">
<itemref idref="cover.xhtml"/>
<itemref idref="summary.xhtml"/>
<itemref idref="x001.xhtml"/>
<itemref idref="x002.xhtml"/>
<itemref idref="x003.xhtml"/>
</spine>
<guide>
<reference type="cover" title="封面" href="Text/cover.xhtml"/>
</guide>
</package>
OEBPS/toc.ncx
xml<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN"
"http://www.daisy.org/z3986/2005/ncx-2005-1.dtd">
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
<head>
<meta name="dtb:uid" content="urn:uuid:通用唯一识别码"/>
<meta name="dtb:depth" content="1"/>
<meta name="dtb:totalPageCount" content="0"/>
<meta name="dtb:maxPageNumber" content="0"/>
</head>
<docTitle>
<text>百年孤独</text>
</docTitle>
<navMap>
<navPoint id="navPoint-1" playOrder="1">
<navLabel>
<text>封面</text>
</navLabel>
<content src="Text/cover.xhtml"/>
</navPoint>
<navPoint id="navPoint-2" playOrder="2">
<navLabel>
<text>简介</text>
</navLabel>
<content src="Text/summary.xhtml"/>
</navPoint>
<navPoint id="navPoint-3" playOrder="3">
<navLabel>
<text>第一章</text>
</navLabel>
<content src="Text/001.xhtml"/>
</navPoint>
<navPoint id="navPoint-4" playOrder="4">
<navLabel>
<text>第二章</text>
</navLabel>
<content src="Text/002.xhtml"/>
</navPoint>
<navPoint id="navPoint-5" playOrder="5">
<navLabel>
<text>第三章</text>
</navLabel>
<content src="Text/003.xhtml"/>
</navPoint>
</navMap>
</ncx>
OEBPS/Images/
图片目录,封面为 cover.jpg
,在文章中使用 ../Images/xxx.jpg
路径引用图片
OEBPS/Text/
文章目录,cover.xhtml
为封面页,summary.xhtml
为简介页,分别如下
OEBPS/Text/cover.xhtml
html<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Cover</title>
</head>
<body>
<div style="text-align: center; padding: 0pt; margin: 0pt;">
<svg xmlns="http://www.w3.org/2000/svg" height="100%" preserveAspectRatio="xMidYMid meet" version="1.1" viewBox="0 0 600 800" width="100%" xmlns:xlink="http://www.w3.org/1999/xlink"><image width="600" height="800" xlink:href="../Images/cover.jpg"/></svg>
</div>
</body>
</html>
OEBPS/Text/summary.xhtml
html<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div>
<h1>简介</h1>
<p>内容段 1</p>
<p>内容段 2</p>
</div>
</body>
</html>
001.xhtml, 002.xhtml 等为文章正文内容,一个章节拆分一个文件,其模板如下
html<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div>
<h1>章节标题</h1>
<p>内容段 1</p>
<p>内容段 2</p>
</div>
</body>
</html>
本文作者:五狗子
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明出处!