diff --git a/src/api/src/create_book.py b/src/api/src/create_book.py
index 4922b81..753a566 100644
--- a/src/api/src/create_book.py
+++ b/src/api/src/create_book.py
@@ -514,27 +514,10 @@ wp_copyright: Dict[str, CopyrightData] = {
}
-author_template = """
-
-
-
- About the Author
-
-
- About the Author
-
-
- {avatar}
-
-
-
- {description}
-
-
-
-
-
-"""
+with open("./pdf/cover_and_copyright.html") as reader:
+ copyright_template = reader.read()
+with open("./pdf/author.html") as reader:
+ author_template = reader.read()
class PDFGenerator:
@@ -585,14 +568,7 @@ class PDFGenerator:
yield part["title"]
- cover_file = tempfile.NamedTemporaryFile(suffix=".html")
- cover_file.write(
- f'
'.encode() # A4 Size
- )
-
- with open("./pdf/copyright.html") as reader:
- copyright_template = reader.read()
-
+ # Cover and Copyright Page
copyright_data = wp_copyright[str(self.data["copyright"])]
copyright_image = (
await fetch_cover(copyright_data["image_url"])
@@ -636,10 +612,15 @@ style="margin-bottom: 1rem;">""".format(
if image_block
else about_copyright.replace("{copyright_image}", "")
)
- about_copyright_file = tempfile.NamedTemporaryFile(suffix=".html", delete=True)
- about_copyright_file.write(about_copyright.encode())
- chapters.insert(0, about_copyright_file)
- about_copyright_file.seek(0)
+ about_copyright = about_copyright.replace(
+ "{cover}", f"data:image/jpg;base64,{b64encode(self.cover).decode()}"
+ )
+
+ cover_and_copyright_file = tempfile.NamedTemporaryFile(
+ suffix=".html", delete=True
+ )
+ cover_and_copyright_file.write(about_copyright.encode())
+ cover_and_copyright_file.seek(0)
author_avatar = (
await fetch_cover(
@@ -669,7 +650,7 @@ style="margin-bottom: 1rem;">""".format(
pdfkit.from_file(
[chapter.file.name for chapter in chapters],
self.file.name,
- cover=cover_file.file.name,
+ cover=cover_and_copyright_file.file.name,
toc={
"toc-header-text": "Table of Contents",
"xsl-style-sheet": "./pdf/toc.xsl",
diff --git a/src/api/src/pdf/author.html b/src/api/src/pdf/author.html
new file mode 100644
index 0000000..b0fa63d
--- /dev/null
+++ b/src/api/src/pdf/author.html
@@ -0,0 +1,95 @@
+
+
+
+ About the Author
+
+
+
+ About the Author
+
+
+ {avatar}
+
+
+
+ {description}
+
+
+
+
+
+
diff --git a/src/api/src/pdf/copyright.html b/src/api/src/pdf/cover_and_copyright.html
similarity index 78%
rename from src/api/src/pdf/copyright.html
rename to src/api/src/pdf/cover_and_copyright.html
index ede4616..d02e3d3 100644
--- a/src/api/src/pdf/copyright.html
+++ b/src/api/src/pdf/cover_and_copyright.html
@@ -5,64 +5,42 @@
Copyright Page
+
+

+
+
Copyright Notice
{book_title}
diff --git a/src/api/src/pdf/stylesheet.css b/src/api/src/pdf/stylesheet.css
index 28e88f5..2cb3c93 100644
--- a/src/api/src/pdf/stylesheet.css
+++ b/src/api/src/pdf/stylesheet.css
@@ -68,77 +68,3 @@ p {
line-height: 1.6 !important; /* Improve readability */
margin: 10px 0 !important; /* Space between paragraphs */
}
-
-
-/* Reset */
-#author-body, #author-html {
- margin: 0;
- padding: 0;
- height: 100%;
-}
-
-#author-body {
- font-family: Arial, sans-serif;
- background-color: #f3f4f6;
-}
-
-/* Container centering for older browsers */
-#author-container {
- position: absolute;
- top: 50%;
- left: 50%;
- -webkit-transform: translate(-50%, -50%); /* Old WebKit */
- transform: translate(-50%, -50%);
- width: 90%;
- max-width: 400px;
- text-align: center;
-}
-
-#author-about {
- padding: 20px;
- /* Fallback for older browsers */
- display: block;
- margin: 0 auto;
-}
-
-#author-profile-picture {
- width: 200px;
- height: 200px;
- -webkit-border-radius: 100px; /* Old WebKit */
- border-radius: 100px;
- margin: 0 auto 20px auto;
- display: block;
-}
-
-#author-name {
- font-size: 24px;
- font-weight: bold;
- margin: 0 0 10px 0;
- padding: 0;
-}
-
-#author-link {
- color: #1a202c;
- text-decoration: none;
-}
-
-#author-link:hover {
- color: #4a5568;
- text-decoration: underline;
-}
-
-#author-divider {
- width: 60px;
- height: 2px;
- background-color: #d1d5db;
- border: none;
- margin: 0 auto 20px auto;
-}
-
-#author-bio {
- color: #4b5563;
- line-height: 1.6;
- margin: 0;
- padding: 0;
-}
-