com3dian commited on
Commit
097f902
·
verified ·
1 Parent(s): 96e96c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -52
app.py CHANGED
@@ -149,58 +149,6 @@ 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, 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 = """
191
- @page {
192
- size: A4 landscape;
193
- margin: 20mm;
194
- }
195
- body {
196
- font-family: sans-serif;
197
- }
198
- """
199
- pdf = BytesIO()
200
- HTML(string=html_string).write_pdf(pdf, stylesheets=[CSS(string=css)])
201
- pdf.seek(0)
202
- return pdf
203
-
204
  def generate_pdf(html_string):
205
  css = """
206
  @page {
 
149
  def render_markdown_to_html(markdown_str):
150
  return markdown.markdown(markdown_str)
151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  def generate_pdf(html_string):
153
  css = """
154
  @page {