LoginSignup
2
0

More than 5 years have passed since last update.

Epub に新規画像ページを差し込む。

Posted at

Epubはzipファイルなので、コンソールを使って生成したが、一部コツが必要なのでそれを兼ねてメモ。
そして、ディレクトリ構成はこんな感じのEPubの書籍に、途中のページに画像だけのページを差し込む。

.
├── META-INF
│   ├── com.apple.ibooks.display-options.xml
│   └── container.xml
├── ch001.xhtml
├── ch002.xhtml
├── ch003.xhtml
├── ch004.xhtml
├── ch005.xhtml
├── ch006.xhtml
├── ch007.xhtml
├── ch008.xhtml
├── content.opf
├── cover.xhtml
├── media
│   └── 777.png
├── mimetype
├── nav.xhtml
├── stylesheet.css
├── title_page.xhtml
└── toc.ncx

2 directories, 20 files

展開

適当なディレクトリを作成してそこに展開する。

unzip <epub file path> -d .

ページを追加する

画像ファイルは用意しておいて、 media/testpage.png という名前で保存しておく。

新規作成: ch001-1.xhtml

ch001-1.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="pandoc" />
  <title></title>
  <link rel="stylesheet" type="text/css" href="stylesheet.css" />
</head>
<body>
<section id="section" class="level1 unnumbered">
<img src="media/testpage.png" alt="cover image" />
</section>
</body>
</html>

変更

目次や content.opf に画像ファイルとページを追加してやる必要がある。

ページ順序は「toc.ncx」にある連番になるので、任意の箇所に「」を入れる。

content.opf
<?xml version="1.0" encoding="UTF-8"?>
<package version="3.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="epub-id-1">
  <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
    <dc:identifier id="epub-id-1">urn:uuid:49efbd25-4ba6-46a3-a899-e45f7733b7f1</dc:identifier>
    <dc:date id="epub-date">2015-06-05T09:45:19Z</dc:date>
    <dc:language>en-US</dc:language>
    <meta name="cover" content="777_png" />
    <meta property="dcterms:modified">2015-06-05T09:45:19Z</meta>
  </metadata>
  <manifest>
    <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" />
    <item id="style" href="stylesheet.css" media-type="text/css" />
    <item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav" />
    <item id="cover_xhtml" href="cover.xhtml" media-type="application/xhtml+xml" />
    <item id="title_page_xhtml" href="title_page.xhtml" media-type="application/xhtml+xml" />
    <item id="ch001_xhtml" href="ch001.xhtml" media-type="application/xhtml+xml" />
    <item id="ch001-1_xhtml" href="ch001-1.xhtml" media-type="application/xhtml+xml" />
    <item id="ch002_xhtml" href="ch002.xhtml" media-type="application/xhtml+xml" />
    <item id="ch003_xhtml" href="ch003.xhtml" media-type="application/xhtml+xml" />
    <item id="ch004_xhtml" href="ch004.xhtml" media-type="application/xhtml+xml" />
    <item id="ch005_xhtml" href="ch005.xhtml" media-type="application/xhtml+xml" />
    <item id="ch006_xhtml" href="ch006.xhtml" media-type="application/xhtml+xml" />
    <item id="ch007_xhtml" href="ch007.xhtml" media-type="application/xhtml+xml" />
    <item id="ch008_xhtml" href="ch008.xhtml" media-type="application/xhtml+xml" />
    <item properties="cover-image" id="777_png" href="media/777.png" media-type="image/png" />
    <item properties="cover-image" id="testpage_png" href="media/testpage.png" media-type="image/png" />
  </manifest>
  <spine toc="ncx" page-progression-direction="rtl">
    <itemref idref="cover_xhtml" linear="no" />
    <itemref idref="title_page_xhtml" linear="no" />
    <itemref idref="nav" linear="no" />
    <itemref idref="ch001_xhtml" />
    <itemref idref="ch001-1_xhtml" />
    <itemref idref="ch002_xhtml" />
    <itemref idref="ch003_xhtml" />
    <itemref idref="ch004_xhtml" />
    <itemref idref="ch005_xhtml" />
    <itemref idref="ch006_xhtml" />
    <itemref idref="ch007_xhtml" />
    <itemref idref="ch008_xhtml" />
  </spine>
  <guide>
    <reference type="toc" title="UNTITLED" href="nav.xhtml" />
    <reference type="cover" title="Cover" href="cover.xhtml" />
  </guide>
</package>
toc.ncx
<?xml version="1.0" encoding="UTF-8"?>
<ncx version="2005-1" xmlns="http://www.daisy.org/z3986/2005/ncx/">
  <head>
    <meta name="dtb:uid" content="urn:uuid:49efbd25-4ba6-46a3-a899-e45f7733b7f1" />
    <meta name="dtb:depth" content="1" />
    <meta name="dtb:totalPageCount" content="0" />
    <meta name="dtb:maxPageNumber" content="0" />
    <meta name="cover" content="777_png" />
  </head>
  <docTitle>
    <text>UNTITLED</text>
  </docTitle>
  <navMap>
    <navPoint id="navPoint-0">
      <navLabel>
        <text></text>
      </navLabel>
      <content src="title_page.xhtml" />
    </navPoint>
    <navPoint id="navPoint-1" playOrder="1">
      <navLabel>
        <text></text>
      </navLabel>
      <content src="ch001.xhtml" />
      <content src="ch001-1.xhtml" />
      <navPoint id="navPoint-2" playOrder="2">
        <navLabel>
          <text>イントロダクション</text>
        </navLabel>
        <content src="ch002.xhtml" />
      </navPoint>
      <navPoint id="navPoint-3" playOrder="3">
        <navLabel>
          <text>∞books</text>
        </navLabel>
        <content src="ch003.xhtml" />
      </navPoint>
      <navPoint id="navPoint-4" playOrder="4">
        <navLabel>
          <text>Sakaseru</text>
        </navLabel>
        <content src="ch004.xhtml" />
      </navPoint>
      <navPoint id="navPoint-5" playOrder="5">
        <navLabel>
          <text>Ingram</text>
        </navLabel>
        <content src="ch005.xhtml" />
      </navPoint>
      <navPoint id="navPoint-6" playOrder="6">
        <navLabel>
          <text>Dr.JOY</text>
        </navLabel>
        <content src="ch006.xhtml" />
      </navPoint>
      <navPoint id="navPoint-7" playOrder="7">
        <navLabel>
          <text>HADO</text>
        </navLabel>
        <content src="ch007.xhtml" />
      </navPoint>
      <navPoint id="navPoint-8" playOrder="8">
        <navLabel>
          <text>おわりに</text>
        </navLabel>
        <content src="ch008.xhtml" />
      </navPoint>
    </navPoint>
  </navMap>
</ncx>
nav.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
  <head>
    <title>UNTITLED</title>
    <link rel="stylesheet" type="text/css" href="stylesheet.css" />
  </head>
  <body>
    <nav epub:type="toc">
      <h1 id="toc-title">UNTITLED</h1>
      <ol class="toc">
        <li id="toc-li-1">
          <a href="ch001.xhtml"></a>
          <a href="ch001-1.xhtml"></a>
          <ol class="toc">
            <li id="toc-li-2">
              <a href="ch002.xhtml">イントロダクション</a>
            </li>
            <li id="toc-li-3">
              <a href="ch003.xhtml">∞books</a>
            </li>
            <li id="toc-li-4">
              <a href="ch004.xhtml">Sakaseru</a>
            </li>
            <li id="toc-li-5">
              <a href="ch005.xhtml">Ingram</a>
            </li>
            <li id="toc-li-6">
              <a href="ch006.xhtml">Dr.JOY</a>
            </li>
            <li id="toc-li-7">
              <a href="ch007.xhtml">HADO</a>
            </li>
            <li id="toc-li-8">
              <a href="ch008.xhtml">おわりに</a>
            </li>
          </ol>
        </li>
      </ol>
    </nav>
  </body>
</html>

再生成

mimetype は初めに保存しないといけないので、先に保存するようにする。

> zip -0 ../test.epub mimetype
> zip -r ../test.epub * -x mimetype

参考

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0