Added background paper to epub output.

This commit is contained in:
Mark Wolfman
2021-07-14 13:01:49 -05:00
parent 70cb8ae30f
commit ee7d5de601
3 changed files with 13 additions and 2 deletions
+11 -1
View File
@@ -1,6 +1,7 @@
from typing import Mapping from typing import Mapping
from html.parser import HTMLParser from html.parser import HTMLParser
import re import re
from pathlib import Path
from ebooklib import epub, ITEM_STYLE from ebooklib import epub, ITEM_STYLE
from docutils import core from docutils import core
@@ -58,8 +59,17 @@ def create_epub(
content=style, content=style,
) )
book.add_item(css) book.add_item(css)
toc = ["nav"] # Add paper background
with open(Path(__file__).parent / "forms/paper.jpg", mode="rb") as fp:
bg_img = fp.read()
paper = epub.EpubItem(
file_name="images/paper.jpg",
media_type="image/jpeg",
content=bg_img,
)
book.add_item(paper)
# Create the separate chapters # Create the separate chapters
toc = ["nav"]
html_chapters = [] html_chapters = []
for chap_title, content in chapters.items(): for chap_title, content in chapters.items():
chap_fname = chap_title.replace(" - ", "-").replace(" ", "_").lower() chap_fname = chap_title.replace(" - ", "-").replace(" ", "_").lower()
+2 -1
View File
@@ -5,7 +5,8 @@ h1, h2, h3, h4, h5, h6 {
font-family: sans-serif; font-family: sans-serif;
} }
body { body {
background: #f4ecdb; /* background: #f4ecdb; */
background-image: url("../images/paper.jpg");
} }
table { table {
/* background: #ECEEE3; */ /* background: #ECEEE3; */
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB