From 758b14fd153d22b685448fd2ee5253496a7952bb Mon Sep 17 00:00:00 2001 From: TheOnlyWayUp Date: Tue, 10 Dec 2024 18:34:27 +0000 Subject: [PATCH] feat(api): Merge PDF Templates --- src/api/src/pdf/author.html | 95 ------- src/api/src/pdf/book.html | 54 ++++ src/api/src/pdf/cover_and_copyright.html | 171 ------------ src/api/src/pdf/footer.html | 30 -- src/api/src/pdf/stylesheet.css | 336 ++++++++++++++++++++++- 5 files changed, 386 insertions(+), 300 deletions(-) delete mode 100644 src/api/src/pdf/author.html create mode 100644 src/api/src/pdf/book.html delete mode 100644 src/api/src/pdf/cover_and_copyright.html delete mode 100644 src/api/src/pdf/footer.html diff --git a/src/api/src/pdf/author.html b/src/api/src/pdf/author.html deleted file mode 100644 index b0fa63d..0000000 --- a/src/api/src/pdf/author.html +++ /dev/null @@ -1,95 +0,0 @@ - - - - About the Author - - - -

About the Author

-
-
- {avatar} -

{username}

-
-

- {description} -

-
-
- - - diff --git a/src/api/src/pdf/book.html b/src/api/src/pdf/book.html new file mode 100644 index 0000000..5fa8482 --- /dev/null +++ b/src/api/src/pdf/book.html @@ -0,0 +1,54 @@ + + + + + + + {book_title} + +
+ Cover +
+ + + +
+ +
+ +

About the Author

+
+
+ {avatar} +

{username}

+
+

+ {description} +

+
+
+ \ No newline at end of file diff --git a/src/api/src/pdf/cover_and_copyright.html b/src/api/src/pdf/cover_and_copyright.html deleted file mode 100644 index 29ff237..0000000 --- a/src/api/src/pdf/cover_and_copyright.html +++ /dev/null @@ -1,171 +0,0 @@ - - - - - - Copyright Page - - - -
- Book Cover -
- - - - - \ No newline at end of file diff --git a/src/api/src/pdf/footer.html b/src/api/src/pdf/footer.html deleted file mode 100644 index ff52492..0000000 --- a/src/api/src/pdf/footer.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - -
- | -
- \ No newline at end of file diff --git a/src/api/src/pdf/stylesheet.css b/src/api/src/pdf/stylesheet.css index 4a09d41..4d04b10 100644 --- a/src/api/src/pdf/stylesheet.css +++ b/src/api/src/pdf/stylesheet.css @@ -52,10 +52,114 @@ -h1 { + + +@page { + margin: 2cm 2cm 3cm 2cm; + size: 148mm 210mm; +} + +@page :left { + @bottom-left { + content: counter(page); + position: absolute; + z-index: -1; + } + @bottom-right { + content: string(heading); + position: absolute; + z-index: -1; + } +} + +@page :right { + @bottom-left { + content: string(heading); + position: absolute; + z-index: -1; + } + @bottom-right { + content: counter(page); + position: absolute; + z-index: -1; + } +} + +@page full { + @bottom-right { + content: none; + } + + @bottom-left { + content: none; + } + + background: black; + margin: 0; +} + +@page :blank { + @bottom-right { + content: none; + } + + @bottom-left { + content: none; + } +} + +@page clean { + @bottom-right { + content: none; + } + + @bottom-left { + content: none; + } +} + +html { + counter-reset: h2-counter; + font-size: 10pt; +} +body { + margin: 0; +} + +p { + line-height: 2; + text-align: justify; +} +img { + display: block; + margin: 2em auto; + max-width: 70%; +} + + +#contents { + border-bottom: 1px dashed rgb(100,000,100); + h2 { + font-family: "PT Serif", serif; + font-weight: 400; + font-style: normal; + } + padding-top: 5px; +} + +.chapter-title { + counter-increment: h2-counter; + display: flex; + flex-direction: column; + font-size: 3em; + height: 6cm; + justify-content: flex-end; + margin: 0; + string-set: heading content(); text-align: center; - font-family: "PT Serif", serif !important; - font-weight: 700 !important; + + font-family: "PT Serif", serif; + font-weight: 700; font-style: normal !important; font-size: 36px !important; /* Uniform size */ margin-bottom: 20px; /* Space below the heading */ @@ -63,12 +167,84 @@ h1 { padding-bottom: 10px; /* Space between text and line */ } + p { font-size: 16px !important; /* Standardize paragraph size */ line-height: 1.6 !important; /* Improve readability */ margin: 10px 0 !important; /* Space between paragraphs */ } +.chapter-title::before { + content: "Chapter " counter(h2-counter) " "; + display: block; + font-size: 1.2rem; + font-weight: normal; + line-height: 1; +} + +section { + break-after: right; +} + + + +#contents { + page: clean; +} +#contents p { + font-size: 2em; +} +#contents ul { + display: block; + margin: 1em 0; + padding: 0; +} +#contents li { + display: block; +} +#contents a { + color: inherit; + text-decoration: none; +} +#contents a::before { + content: target-counter(attr(href), h2-counter) '. ' target-text(attr(href)); + width: 100%; +} +#contents a::after { + content: target-counter(attr(href), page); + text-align: end; +} + +.outro { + border-radius: 50% 50% 0 0 / 15mm 15mm 0 0; + display: block; + height: 90mm; + left: -30mm; + max-width: none; + object-fit: cover; + position: absolute; + top: 120mm; + width: 168mm; + z-index: -1; +} + +.fullpage { + page: full; +} +.fullpage img { + bottom: 0; + height: 210mm; + left: 0; + margin: 0; + max-width: none; + object-fit: cover; + position: absolute; + width: 148mm; + z-index: 1; +} +.fullpage:last-child { + break-before: left; +} a { font-size: 0.9rem; @@ -87,4 +263,156 @@ a { a:hover { text-decoration: underline; color: #2c5282; -} \ No newline at end of file +} + + +/* 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; + } + +#copyright-container { + max-width: 600px; + margin: 60px auto; + text-align: center !important; + font-family: Georgia, serif !important; + line-height: 1.6 !important; + color: #333 !important; +} + +#copyright-notice { + font-size: 24px; + margin-bottom: 4px; + border-bottom: 1px solid #333; + padding-bottom: 8px; + color: #1a1a1a; +} + +#copyright-title { + font-size: 28px; + margin: 24px 0 4px 0; + color: #1a1a1a; +} + +#copyright-author { + font-size: 18px; + margin: 0 0 32px 0; + color: #444; + text-align: center; +} + +#copyright-license-image { + margin: 20px 0; + width: 88px; + height: 31px; + + display: block; + margin-left: auto; + margin-right: auto; +} + +#copyright-copyright { + font-size: 16px; + margin: 16px 0; + text-align: center; + +} + +#copyright-rights { + font-size: 14px; + color: #666; + margin: 8px 0; + text-align: center; + +} + +#copyright-printing { + font-size: 14px; + color: #666; + margin: 8px 0; + text-align: center; + +} + +#copyright-separator { + width: 100%; + max-width: 400px; + height: 1px; + background: #e2e8f0; + position: relative; + margin: 2rem 1rem; + + /* Gradient fallback */ + background: -webkit-gradient(linear, left top, right top, from(transparent), color-stop(#718096), to(transparent)); + background: -webkit-linear-gradient(left, transparent, #718096, transparent); + background: -moz-linear-gradient(left, transparent, #718096, transparent); + background: -o-linear-gradient(left, transparent, #718096, transparent); + background: linear-gradient(to right, transparent, #718096, transparent); +} + +#copyright-ex-libris { + font-size: 1.5rem; + font-style: italic; + color: #4a5568; + margin: 2rem 0; + text-align: center; +} + +#copyright-link { + font-size: 14px; +}