From 554eaf82da520ee3f9f7fef365e98079fabe14fc Mon Sep 17 00:00:00 2001 From: assafelovic Date: Mon, 18 Mar 2024 10:10:25 +0200 Subject: [PATCH] added pdf stylying --- backend/utils.py | 2 +- frontend/pdf_styles.css | 53 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 frontend/pdf_styles.css diff --git a/backend/utils.py b/backend/utils.py index d60adb757..b2681af54 100644 --- a/backend/utils.py +++ b/backend/utils.py @@ -33,7 +33,7 @@ async def write_md_to_pdf(text: str) -> str: md2pdf(f"{file_path}.pdf", md_content=None, md_file_path=f"{file_path}.md", - css_file_path=None, + css_file_path="./frontend/pdf_styles.css", base_url=None) print(f"Report written to {file_path}.pdf") except Exception as e: diff --git a/frontend/pdf_styles.css b/frontend/pdf_styles.css new file mode 100644 index 000000000..bb859e351 --- /dev/null +++ b/frontend/pdf_styles.css @@ -0,0 +1,53 @@ +body { + font-family: 'Libre Baskerville', serif; + font-size: 12pt; /* standard size for academic papers */ + line-height: 1.6; /* for readability */ + color: #333; /* softer on the eyes than black */ + background-color: #fff; /* white background */ + margin: 0; + padding: 0; +} + +h1, h2, h3, h4, h5, h6 { + font-family: 'Libre Baskerville', serif; + color: #000; /* darker than the body text */ + margin-top: 1em; /* space above headers */ +} + +h1 { + font-size: 2em; /* make h1 twice the size of the body text */ +} + +h2 { + font-size: 1.5em; +} + +/* Add some space between paragraphs */ +p { + margin-bottom: 1em; +} + +/* Style for blockquotes, often used in academic papers */ +blockquote { + font-style: italic; + margin: 1em 0; + padding: 1em; + background-color: #f9f9f9; /* a light grey background */ +} + +/* You might want to style tables, figures, etc. too */ +table { + border-collapse: collapse; + width: 100%; +} + +table, th, td { + border: 1px solid #ddd; + text-align: left; + padding: 8px; +} + +th { + background-color: #f2f2f2; + color: black; +} \ No newline at end of file