Spaces:
Sleeping
Sleeping
File size: 2,058 Bytes
696ebd6 747d1d9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
import streamlit as st
import fitz # PyMuPDF
from huggingface_hub import hf_hub_download
st.title("Ruthvik's Intro")
# Sidebar navigation
st.sidebar.title("Navigation")
sections = ["Profile Summary", "Functional Skills", "Technical Skills", "Work Experience", "Education", "Research and Publications", "Certifications"]
for section in sections:
st.sidebar.markdown(f"[{section}](#{section.lower().replace(' ', '-')})")
# Replace with your Hugging Face repository details
repo_id = "ruthvik7382/resume"
file_path_in_repo = "Ruthvik-Resume.pdf"
# Download the PDF file from the Hugging Face repository
pdf_path = hf_hub_download(repo_id=repo_id, filename=file_path_in_repo)
# Display PDF in Streamlit
with open(pdf_path, 'rb') as file:
pdf_data = file.read()
st.subheader("Uploaded Resume")
st.download_button(label="Download Resume", data=pdf_data, file_name="resume.pdf")
# Read and display the PDF content
doc = fitz.open(pdf_path)
text = ""
for page_num in range(len(doc)):
page = doc.load_page(page_num)
text += page.get_text()
# Function to create HTML anchors for each section
def create_anchor(section_name):
anchor = f"<h2 id='{section_name.lower().replace(' ', '-')}'>{section_name}</h2>"
return anchor
# Split the text content into sections
content_sections = {
"Profile Summary": "",
"Functional Skills": "",
"Technical Skills": "",
"Work Experience": "",
"Education": "",
"Research and Publications": "",
"Certifications": ""
}
# Assuming that each section starts with its title in the text,
# the following logic tries to split the text into respective sections
current_section = None
for line in text.split("\n"):
stripped_line = line.strip()
if stripped_line in content_sections:
current_section = stripped_line
if current_section:
content_sections[current_section] += line + "\n"
# Display each section with an HTML anchor
for section in sections:
st.markdown(create_anchor(section), unsafe_allow_html=True)
st.text(content_sections[section])
|