KajetanNiewczas commited on
Commit
1f32a8e
·
1 Parent(s): 4bd370e

Fix the presentation preview

Browse files
Files changed (2) hide show
  1. .gitignore +1 -1
  2. src/interface/gradio_interface.py +11 -3
.gitignore CHANGED
@@ -1,7 +1,7 @@
1
  # Custom Python .gitignore file
2
  .DS_Store
3
  activate_poetry.sh
4
-
5
 
6
 
7
  # Byte-compiled / optimized / DLL files
 
1
  # Custom Python .gitignore file
2
  .DS_Store
3
  activate_poetry.sh
4
+ uploaded_docs/*
5
 
6
 
7
  # Byte-compiled / optimized / DLL files
src/interface/gradio_interface.py CHANGED
@@ -23,9 +23,17 @@ def upload_and_update_list(files: list, uploaded_list) -> tuple[str, list[str]]:
23
  def generate_iframe(file_path):
24
  if not file_path:
25
  return ""
26
- return (
27
- f'<embed src="{file_path}" type="application/pdf" width="100%" height="600px">'
28
- )
 
 
 
 
 
 
 
 
29
 
30
 
31
  theme = gr.themes.Monochrome(
 
23
  def generate_iframe(file_path):
24
  if not file_path:
25
  return ""
26
+ else:
27
+ with open(file_path, "rb") as f:
28
+ base64_pdf = base64.b64encode(f.read()).decode("utf-8")
29
+ # pdf_display = f'''
30
+ # <div style="position:relative; width:100%; padding-top:76.5%;">
31
+ # <iframe src="data:application/pdf;base64,{base64_pdf}#view=FitH"
32
+ # style="position:absolute; top:0; left:0; width:100%; height:100%; border:none;">
33
+ # </iframe></div>
34
+ # '''
35
+ pdf_display = f'<iframe width="100%" height="auto" src="data:application/pdf;base64,{base64_pdf}"></iframe>'
36
+ return pdf_display
37
 
38
 
39
  theme = gr.themes.Monochrome(