電子書籍のフォーマットとしてePubが選ばれることが多いのですが、書籍によってはPDFの場合もあります。PDFは文字サイズが変更できないので、スマートフォンでは読みづらいこともあります。ePubの方が良いと思っている人も多いのではないでしょうか。 そこで使ってみたいのがpdf2epubEXです。PDFをレイアウトそのままにePubに変換してくれるソフトウェアです。

pdf2epubEXの使い方

実行例です。Dockerで使えるのでとても簡単です。

$ docker run -ti --rm -v `pwd`:/temp dodeeric/pdf2epubex pdf2epubEX doc.pdf 
-------------------------------------------------------------------------------------------------
Book/PDF Width: 8.27 inches / 21.0 cm
Book/PDF Height: 11.69 inches / 29.7 cm
Factor ratio (Height / Width): 1.41
ePub Viewport (Width x Height): 900 pixels x 1272 pixels
-------------------------------------------------------------------------------------------------
Do you want to see more information on the PDF file? (y or n) [default: n]: 
======================
Caution:
- if you chose png or jpg (bitmap formats), the vector images will be converted in bitmap images (rasterized).
- if you chose svg (vector and bitmap format), the vector images will remain in vector format, but: a) you cannot chose the resolution of the bitmap images (it is the one from the PDF); b) the bitmap images will be included in the svg files (Base64 coded); c) this format is not always correctly rendered by eBook readers; d) the generated epub file is not always passing the epub check.
======================
If you want, you can hit <enter> to all the next questions.
Format of the images in the epub (png, jpg or svg) [default: jpg]: 
Resolution of the images in the epub in dpi (e.g.: 150 or 300) [default: 150]: 
  :
Preprocessing: 150/150
Working: 150/150

Done

実行したファイルです。トンボも含めて忠実に再現されています。

画像も問題なく維持されています。

pdf2epubEXはPDFを綺麗にHTML化するpdf2htmlEXを使ってePub化しています。変換直後の状態では文字サイズは変更できませんが、ePubであれば編集ソフトウェアもあるので、それで変更すれば良いでしょう。ePubになれば、自由度はぐっと高まるはずです。

pdf2epubEXはShellスクリプト製のオープンソース・ソフトウェア(MIT License)です。

dodeeric/pdf2epubEX: Tool to convert a PDF file (myfile.pdf) to a fixed layout ePub file (myfile.epub). The layout is perfectly retained and all the fonts are embedded.