com3dian commited on
Commit
da8874f
·
verified ·
1 Parent(s): 2e52433

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -28
app.py CHANGED
@@ -149,34 +149,42 @@ if (summ_text is not None) or ('summ_text' in st.session_state):
149
  def render_markdown_to_html(markdown_str):
150
  return markdown.markdown(markdown_str)
151
 
152
- def create_pdf_from_markdown_strings(markdown_strings):
153
- html_pages = [render_markdown_to_html(md) for md in markdown_strings]
154
-
155
- # Combine HTML content with page breaks and add a style section for font size and margins
156
- combined_html = '''
157
- <html>
158
- <head>
159
- <style>
160
- .page {
161
- font-size: 16pt; /* Adjust the font size as needed */
162
- }
163
- </style>
164
- </head>
165
- <body>
166
- '''
167
- for i, page in enumerate(html_pages):
168
- combined_html += f'<div class="page">{page}</div>'
169
- if i < len(html_pages) - 1: # Only add page break after if it's not the last page
170
- combined_html += '<div style="page-break-after: always;"></div>'
171
- combined_html += '</body></html>'
172
-
173
- # PDF options: landscape orientation and page size
174
- options = {
175
- 'page-size': 'A4',
176
- 'orientation': 'Landscape'
177
- }
178
-
179
- return combined_html
 
 
 
 
 
 
 
 
180
 
181
  def generate_pdf(html_string):
182
  css = """
 
149
  def render_markdown_to_html(markdown_str):
150
  return markdown.markdown(markdown_str)
151
 
152
+ def create_pdf_from_markdown_strings(markdown_strings):
153
+ html_pages = [render_markdown_to_html(md) for md in markdown_strings]
154
+
155
+ # Combine HTML content with page breaks and add a style section for font size, margins, and background color
156
+ combined_html = '''
157
+ <html>
158
+ <head>
159
+ <style>
160
+ body {
161
+ background-color: #45474B; /* Set background color to grey */
162
+ color: #F5F7F8; /* Set font color to white */
163
+ }
164
+ .page {
165
+ font-size: 16pt; /* Adjust the font size as needed */
166
+ margin: 1cm; /* Optional: adjust margins */
167
+ color: #F5F7F8; /* Ensure font color is white within pages */
168
+ }
169
+ </style>
170
+ </head>
171
+ <body>
172
+ '''
173
+ for i, page in enumerate(html_pages):
174
+ combined_html += f'<div class="page">{page}</div>'
175
+ if i < len(html_pages) - 1: # Only add page break if it's not the last page
176
+ combined_html += '<div style="page-break-after: always;"></div>'
177
+ combined_html += '</body></html>'
178
+
179
+ # PDF options: landscape orientation and page size
180
+ options = {
181
+ 'page-width': '297mm', # Width of A4 page in landscape mode
182
+ 'page-height': '210mm', # Height of A4 page in landscape mode
183
+ 'orientation': 'Landscape'
184
+ }
185
+
186
+ return combined_html, options
187
+
188
 
189
  def generate_pdf(html_string):
190
  css = """