Esempio n. 1
0
from epub2 import EpubBuilder, EpubNavPoint

epub = EpubBuilder("contents.epub")

epub.identifier = "contents"
epub.title = "Deep Table of Contents"

epub.metadata.add_language("en")

toc1 = EpubNavPoint("toc.1", "1. Chapter 1", "text.html#toc.1")
toc2 = EpubNavPoint("toc.2", "2. Chapter 2", "text.html#toc.2")
toc3 = EpubNavPoint("toc.3", "3. Chapter 3", "text.html#toc.3")
epub.add_navpoint(toc1)
epub.add_navpoint(toc2)
epub.add_navpoint(toc3)

toc11 = EpubNavPoint("toc.1.1", "1.1. Section 1", "text.html#toc.1.1")
toc12 = EpubNavPoint("toc.1.2", "1.2. Section 2", "text.html#toc.1.2")
toc1.append(toc11)
toc1.append(toc12)

toc21 = EpubNavPoint("toc.2.1", "2.1. Section 1", "text.html#toc.2.1", [
    EpubNavPoint("toc.2.1.1", "2.1.1. Subsection 1", "text.html#toc.2.1.1"),
    EpubNavPoint("toc.2.1.2", "2.1.2. Subsection 2", "text.html#toc.2.1.2"),
    EpubNavPoint("toc.2.1.3", "2.1.3. Subsection 3", "text.html#toc.2.1.3")
])
toc22 = EpubNavPoint("toc.2.2", "2.2. Section 2", "text.html#toc.2.2")
toc2.append(toc21)
toc2.append(toc22)

epub.open()
Esempio n. 2
0
from epub2 import EpubBuilder, EpubNavPoint

epub = EpubBuilder("sample.epub")
epub.open()

epub.identifier = "sample"
epub.title = "Sample ePUB file"

epub.metadata.add_title("Title N°2")
epub.metadata.add_title("Title N°3")
epub.metadata.add_creator("Creator N°1")
epub.metadata.add_creator("Creator N°2", role="aut")
epub.metadata.add_creator("Creator N°3", file_as="Creator 3", role="oth")
epub.metadata.add_subject("Subject N°1")
epub.metadata.add_subject("Subject N°2")
epub.metadata.set_description("Description")
epub.metadata.set_publisher("Publisher")
epub.metadata.add_contributor("Contributor N°1")
epub.metadata.add_contributor("Contributor N°2", role="aut")
epub.metadata.add_contributor("Contributor N°3", file_as="Contributor 3", role="oth")
epub.metadata.add_date("2014")
epub.metadata.add_date("2014-12", event="modification")
epub.metadata.add_date("2014-12-25", event="publication")
epub.metadata.set_type("type")
epub.metadata.set_format("format")
epub.metadata.add_identifier("uuid002")
epub.metadata.add_identifier("uuid003", "myid", "scheme")
epub.metadata.set_source("source")
epub.metadata.add_language("en-US")
epub.metadata.add_language("fr-fr")
epub.metadata.add_language("de")