// Navigate between sections function nextSection(currentId, nextId) { document.getElementById(currentId).style.display = 'none'; document.getElementById(nextId).style.display = 'block'; } // Add more entries for Work Experience or Education function addMore(className) { const entry = document.querySelector(`.${className}`); const clone = entry.cloneNode(true); clone.querySelectorAll('input, textarea').forEach(el => el.value = ''); entry.parentNode.appendChild(clone); } // Generate the PDF resume function generateResume() { const { jsPDF } = window.jspdf; const doc = new jsPDF(); // Collect data from the form const style = document.getElementById('resume-style').value; const name = document.getElementById('name').value; const title = document.getElementById('title').value; const email = document.getElementById('email').value; const phone = document.getElementById('phone').value; const summary = document.getElementById('summary').value; // Work Experience const workEntries = document.querySelectorAll('.work-entry'); const workExperience = []; workEntries.forEach(entry => { const company = entry.querySelector('.company').value; const role = entry.querySelector('.role').value; const duration = entry.querySelector('.duration').value; const achievements = entry.querySelector('.achievements').value; if (company && role && duration) { workExperience.push({ company, role, duration, achievements }); } }); // Education const eduEntries = document.querySelectorAll('.edu-entry'); const education = []; eduEntries.forEach(entry => { const degree = entry.querySelector('.degree').value; const institution = entry.querySelector('.institution').value; const year = entry.querySelector('.year').value; if (degree && institution && year) { education.push({ degree, institution, year }); } }); // Skills const skills = document.getElementById('skills').value.split(',').map(s => s.trim()); // Style-specific settings let font = 'helvetica'; let headingColor = [0, 0, 0]; let textColor = [0, 0, 0]; let lineSpacing = 5; let sectionSpacing = 10; if (style === 'creative') { font = 'times'; headingColor = [0, 102, 204]; // Blue textColor = [51, 51, 51]; // Dark gray } else if (style === 'academic') { font = 'courier'; headingColor = [0, 0, 0]; textColor = [0, 0, 0]; lineSpacing = 6; sectionSpacing = 12; } // Set font for the entire document doc.setFont(font); let y = 20; // Starting y-position // Contact Information doc.setFontSize(20); doc.setTextColor(...headingColor); doc.setFont(font, 'bold'); doc.text(name, 105, y, { align: 'center' }); y += 10; doc.setFontSize(14); doc.setTextColor(...textColor); doc.setFont(font, 'normal'); doc.text(title, 105, y, { align: 'center' }); y += 10; doc.setFontSize(10); doc.text(`Email: ${email} | Phone: ${phone}`, 105, y, { align: 'center' }); y += 10; // Separator line (only for corporate and academic) if (style !== 'creative') { doc.setLineWidth(0.5); doc.line(10, y, 200, y); y += 10; } else { y += 5; } // Professional Summary if (summary) { doc.setFontSize(14); doc.setTextColor(...headingColor); doc.setFont(font, 'bold'); doc.text('PROFESSIONAL SUMMARY', 10, y); y += 7; doc.setFontSize(12); doc.setTextColor(...textColor); doc.setFont(font, 'normal'); const summaryLines = doc.splitTextToSize(summary, 180); doc.text(summaryLines, 10, y); y += summaryLines.length * lineSpacing + sectionSpacing; } // Work Experience if (workExperience.length > 0) { doc.setFontSize(14); doc.setTextColor(...headingColor); doc.setFont(font, 'bold'); doc.text('WORK EXPERIENCE', 10, y); y += 7; doc.setFontSize(12); doc.setTextColor(...textColor); workExperience.forEach(exp => { doc.setFont(font, 'bold'); doc.text(`${exp.company} - ${exp.role}`, 10, y); doc.setFont(font, 'normal'); doc.text(exp.duration, 190, y, { align: 'right' }); y += 5; if (exp.achievements) { const achievementsLines = doc.splitTextToSize(exp.achievements, 180); doc.text(achievementsLines, 10, y); y += achievementsLines.length * lineSpacing + 5; } else { y += 5; } }); y += sectionSpacing; } // Education if (education.length > 0) { doc.setFontSize(14); doc.setTextColor(...headingColor); doc.setFont(font, 'bold'); doc.text('EDUCATION', 10, y); y += 7; doc.setFontSize(12); doc.setTextColor(...textColor); doc.setFont(font, 'normal'); education.forEach(edu => { doc.text(`${edu.degree}, ${edu.institution} (${edu.year})`, 10, y); y += 7; }); y += sectionSpacing; } // Skills if (skills.length > 0 && skills[0] !== '') { doc.setFontSize(14); doc.setTextColor(...headingColor); doc.setFont(font, 'bold'); doc.text('SKILLS', 10, y); y += 7; doc.setFontSize(12); doc.setTextColor(...textColor); doc.setFont(font, 'normal'); const skillsText = skills.join(', '); const skillsLines = doc.splitTextToSize(skillsText, 180); doc.text(skillsLines, 10, y); y += skillsLines.length * lineSpacing; } // Save the PDF doc.save('resume.pdf'); }