API Reference

class epubaker.Epub3
cover_image

Tag your cover image path as a cover

write(filename)

Write to file.

Parameters:filename (str) – file name.
addons_make_toc_page()

Some EPUB reader not supports nav hidden attribute, they just ignor sub section, not fold. So, this member function can make a toc page, with it’s little JS code, it can fold and unfold sections.

You must put the returned file to Epub3.files by yourself.

Returns:xhtml page file
Return type:File
addons_make_image_page(image_path, cover_page_path=None, width=None, heigth=None)

Make xhtml cover page contain the image you given.

You must put the returned file to Epub2.files by yourself

Parameters:
  • image_path – Image path in your Epub2.files
  • cover_page_path – Use this to get relative path to the image path
  • width – Image width, automatic recognition if None
  • heigth – Image heigth, automatic recognition if None
Returns:

Cover xhtml page file.

Return type:

File

files

dict-like.

Store file path and File objects from key and item. Any file you want to package them into the book, you have to use this.

metadata

list-like.

Store metadata, such as author, publisher etc.

see epubaker.metas

spine

list-like.

“The spine defines the default reading order”

store Joint objects.

toc

list-like.

table of contents

store Section objects.

class epubaker.Epub2
write(filename)

Write to file.

Parameters:filename (str) – file name.
addons_make_image_page(image_path, cover_page_path=None, width=None, heigth=None)

Make xhtml cover page contain the image you given.

You must put the returned file to Epub2.files by yourself

Parameters:
  • image_path – Image path in your Epub2.files
  • cover_page_path – Use this to get relative path to the image path
  • width – Image width, automatic recognition if None
  • heigth – Image heigth, automatic recognition if None
Returns:

Cover xhtml page file.

Return type:

File

files

dict-like.

Store file path and File objects from key and item. Any file you want to package them into the book, you have to use this.

metadata

list-like.

Store metadata, such as author, publisher etc.

see epubaker.metas

spine

list-like.

“The spine defines the default reading order”

store Joint objects.

toc

list-like.

table of contents

store Section objects.

class epubaker.File(binary, mime=None, fallback=None)
Parameters:
  • binary (bytes) – binary data
  • mime (str) – mime
  • fallback (str) – file path
binary

as class parmeter

class epubaker.Section(title, href=None)

Store title, href and sub Section objects.

Parameters:
  • title (str) – title of content.
  • href (str) – html link to a file path in Epub.files, can have a bookmark. example: text/a.html#hello
title

as class parameter

href

as class parmeter

subs

list-like, store sub Section objects.

hidden_subs

bool: True for fold sub sections, False unfold.

some reader just don’t show sub sections when this is True,

but I think it’s mean FOLD sub sections and you can unfold it to show subs.

this i for epub3 nav only.

class epubaker.Joint(path, linear=None)
Parameters:
  • path (str) – file path, in Epub.Files.keys()
  • linear (bool) – I don’t know what is this mean. visit http://idpf.org to figure out by yourself.
path

as class parmeter