Spaces:
Sleeping
Sleeping
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]) | |