akarshrajsingh7 commited on
Commit
0889af8
·
1 Parent(s): 1f0f559

PDF Render Issue Fix - Revert to Iframe

Browse files
Files changed (1) hide show
  1. app.py +32 -27
app.py CHANGED
@@ -84,16 +84,19 @@ with tab1:
84
  base64_pdf = b64encode(text_to_pdf_fastify(text)).decode("utf-8")
85
 
86
  # Embedding the PDFs in the HTML
87
- original_display = f"""
88
- <div class="pdf-container" style="height: 500px;">
89
- <embed class="pdfobject" type="application/pdf" title="Modified PDF" src="data:application/pdf;base64,{original_pdf}" style="width: 100%; height: 100%;">
90
- </div>
91
- """
92
- pdf_display = f"""
93
- <div class="pdf-container" style="height: 500px;">
94
- <embed class="pdfobject" type="application/pdf" title="Modified PDF" src="data:application/pdf;base64,{base64_pdf}" style="width: 100%; height: 100%;">
95
- </div>
96
- """
 
 
 
97
  # Compare Logic implementation
98
  if compare:
99
  col1, col2, col3 = st.columns(3)
@@ -153,17 +156,19 @@ with tab2:
153
  # Embedding the PDFs in the HTML
154
  # original_display = f"""<embed class="pdfobject" type="application/pdf" title="Original PDF" src="data:application/pdf;base64,{original_pdf}" style=" width: 100%; height: 150%;">"""
155
  # pdf_display = f"""<embed class="pdfobject" type="application/pdf" title="Modified PDF" src="data:application/pdf;base64,{base64_pdf}" style=" width: 100%; height: 150%;">"""
156
-
157
- original_display = f"""
158
- <div class="pdf-container" style="height: 500px;">
159
- <embed class="pdfobject" type="application/pdf" title="Modified PDF" src="data:application/pdf;base64,{original_pdf}" style="width: 100%; height: 100%;">
160
- </div>
161
- """
162
- pdf_display = f"""
163
- <div class="pdf-container" style="height: 500px;">
164
- <embed class="pdfobject" type="application/pdf" title="Modified PDF" src="data:application/pdf;base64,{base64_pdf}" style="width: 100%; height: 100%;">
165
- </div>
166
- """
 
 
167
 
168
 
169
 
@@ -183,12 +188,12 @@ with tab2:
183
  with st.container(border = True):
184
  st.markdown("<div style='text-align: center;'><strong>Fastified PDF viewer</strong></div>", unsafe_allow_html=True)
185
  st.markdown(pdf_display, unsafe_allow_html=True)
186
- # # Browser Cache Note
187
- # st.markdown(f"""
188
- # <div style='background-color: #FFD580; border-radius: 5px;'>
189
- # <p style='color: black;'><strong>Note</strong> - {note_text}</p>
190
- # </div>
191
- # """, unsafe_allow_html=True)
192
  else:
193
  # No Comparison
194
  col1, col2, col3 = st.columns(3)
 
84
  base64_pdf = b64encode(text_to_pdf_fastify(text)).decode("utf-8")
85
 
86
  # Embedding the PDFs in the HTML
87
+ original_display = f'<iframe src="data:application/pdf;base64,{original_pdf}" width = "100%" height = 600 type="application/pdf" download="original.pdf"></iframe>'
88
+ pdf_display = f'<iframe src="data:application/pdf;base64,{base64_pdf}" width = "100%" height = 600 type="application/pdf" download="Modified.pdf"></iframe>'
89
+
90
+ # original_display = f"""
91
+ # <div class="pdf-container" style="height: 500px;">
92
+ # <embed class="pdfobject" type="application/pdf" title="Modified PDF" src="data:application/pdf;base64,{original_pdf}" style="width: 100%; height: 100%;">
93
+ # </div>
94
+ # """
95
+ # pdf_display = f"""
96
+ # <div class="pdf-container" style="height: 500px;">
97
+ # <embed class="pdfobject" type="application/pdf" title="Modified PDF" src="data:application/pdf;base64,{base64_pdf}" style="width: 100%; height: 100%;">
98
+ # </div>
99
+ # """
100
  # Compare Logic implementation
101
  if compare:
102
  col1, col2, col3 = st.columns(3)
 
156
  # Embedding the PDFs in the HTML
157
  # original_display = f"""<embed class="pdfobject" type="application/pdf" title="Original PDF" src="data:application/pdf;base64,{original_pdf}" style=" width: 100%; height: 150%;">"""
158
  # pdf_display = f"""<embed class="pdfobject" type="application/pdf" title="Modified PDF" src="data:application/pdf;base64,{base64_pdf}" style=" width: 100%; height: 150%;">"""
159
+ original_display = f'<iframe src="data:application/pdf;base64,{original_pdf}" width = "100%" height = 600 type="application/pdf" download="original.pdf"></iframe>'
160
+ pdf_display = f'<iframe src="data:application/pdf;base64,{base64_pdf}" width = "100%" height = 600 type="application/pdf" download="Modified.pdf"></iframe>'
161
+
162
+ # original_display = f"""
163
+ # <div class="pdf-container" style="height: 500px;">
164
+ # <embed class="pdfobject" type="application/pdf" title="Modified PDF" src="data:application/pdf;base64,{original_pdf}" style="width: 100%; height: 100%;">
165
+ # </div>
166
+ # """
167
+ # pdf_display = f"""
168
+ # <div class="pdf-container" style="height: 500px;">
169
+ # <embed class="pdfobject" type="application/pdf" title="Modified PDF" src="data:application/pdf;base64,{base64_pdf}" style="width: 100%; height: 100%;">
170
+ # </div>
171
+ # """
172
 
173
 
174
 
 
188
  with st.container(border = True):
189
  st.markdown("<div style='text-align: center;'><strong>Fastified PDF viewer</strong></div>", unsafe_allow_html=True)
190
  st.markdown(pdf_display, unsafe_allow_html=True)
191
+ # Browser Cache Note
192
+ st.markdown(f"""
193
+ <div style='background-color: #FFD580; border-radius: 5px;'>
194
+ <p style='color: black;'><strong>Note</strong> - {note_text}</p>
195
+ </div>
196
+ """, unsafe_allow_html=True)
197
  else:
198
  # No Comparison
199
  col1, col2, col3 = st.columns(3)