awacke1 commited on
Commit
74c4746
ยท
verified ยท
1 Parent(s): d6bd877

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -5
app.py CHANGED
@@ -364,7 +364,8 @@ def create_and_link_pdfs(source_pdf="TestSource.pdf", target_pdf="TestTarget.pdf
364
  writer.add_page(page)
365
  page = writer.pages[0]
366
  y_position = 800 - (7 * 20)
367
- writer.add_bookmark("Seven Bookmark", 0, [50, y_position])
 
368
  with open(pdf_file, "wb") as f:
369
  writer.write(f)
370
 
@@ -513,7 +514,6 @@ with st.sidebar:
513
  mime="audio/mpeg"
514
  )
515
 
516
- # Existing "Create Linked PDFs" button
517
  if st.button("๐Ÿ“‘ Create Linked PDFs"):
518
  with st.spinner("Creating and linking PDFs..."):
519
  source_pdf, target_pdf = create_and_link_pdfs()
@@ -527,12 +527,10 @@ with st.sidebar:
527
  mime="application/pdf"
528
  )
529
 
530
- # New "Test PDFs" button
531
  if st.button("๐Ÿงช Test PDFs"):
532
  with st.spinner("Generating and testing PDFs..."):
533
  source_pdf, target_pdf = create_and_link_pdfs()
534
  st.success(f"Generated {source_pdf} and {target_pdf}")
535
- # Display PDFs as images
536
  for pdf_file in [source_pdf, target_pdf]:
537
  with open(pdf_file, "rb") as f:
538
  pdf_bytes = f.read()
@@ -541,7 +539,6 @@ with st.sidebar:
541
  st.subheader(f"Preview of {pdf_file}")
542
  for img in images:
543
  st.image(img, caption=f"{pdf_file} Page", use_container_width=True)
544
- # Provide download option
545
  with open(pdf_file, "rb") as f:
546
  st.download_button(
547
  label=f"๐Ÿ’พ Download {pdf_file}",
 
364
  writer.add_page(page)
365
  page = writer.pages[0]
366
  y_position = 800 - (7 * 20)
367
+ # Use add_outline_item instead of add_bookmark
368
+ writer.add_outline_item("Seven Bookmark", 0, dest=page, fit="/XYZ", left=50, top=y_position)
369
  with open(pdf_file, "wb") as f:
370
  writer.write(f)
371
 
 
514
  mime="audio/mpeg"
515
  )
516
 
 
517
  if st.button("๐Ÿ“‘ Create Linked PDFs"):
518
  with st.spinner("Creating and linking PDFs..."):
519
  source_pdf, target_pdf = create_and_link_pdfs()
 
527
  mime="application/pdf"
528
  )
529
 
 
530
  if st.button("๐Ÿงช Test PDFs"):
531
  with st.spinner("Generating and testing PDFs..."):
532
  source_pdf, target_pdf = create_and_link_pdfs()
533
  st.success(f"Generated {source_pdf} and {target_pdf}")
 
534
  for pdf_file in [source_pdf, target_pdf]:
535
  with open(pdf_file, "rb") as f:
536
  pdf_bytes = f.read()
 
539
  st.subheader(f"Preview of {pdf_file}")
540
  for img in images:
541
  st.image(img, caption=f"{pdf_file} Page", use_container_width=True)
 
542
  with open(pdf_file, "rb") as f:
543
  st.download_button(
544
  label=f"๐Ÿ’พ Download {pdf_file}",