Employee Handbook Generator

Employee Handbook Generator

Create a professional employee handbook in minutes.

Let's start with the basics.

Select the policies to include.

Review and customize the generated policies.

You can edit the text for each section below. Use `[Company Name]` where you want your company's name to appear.

Final Handbook

${content.replace(/\n/g, '
')}

`; } handbookOutputDiv.innerHTML = finalHtml; } /** * **FIXED** PDF Download Functionality * This function now correctly handles multi-page content by rendering the entire * handbook content to a single canvas and then slicing that canvas image across * multiple PDF pages. This prevents text from being cut off. */ function downloadPdf() { const handbookContent = document.getElementById('handbook-output'); const companyName = handbookData.companyName || 'Company'; const { jsPDF } = window.jspdf; if (!handbookContent || !jsPDF) { alert('PDF generation library not found.'); return; } const originalButtonText = downloadPdfBtn.innerHTML; downloadPdfBtn.innerHTML = 'Generating PDF...'; downloadPdfBtn.disabled = true; html2canvas(handbookContent, { scale: 2, // Use higher scale for better text clarity useCORS: true, width: handbookContent.scrollWidth, height: handbookContent.scrollHeight }).then(canvas => { const imgData = canvas.toDataURL('image/png'); // **FIX**: Define imgData from the canvas const pdf = new jsPDF({ orientation: 'portrait', unit: 'pt', format: 'letter' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const canvasWidth = canvas.width; const canvasHeight = canvas.height; const ratio = canvasHeight / canvasWidth; // **FIX**: Correct aspect ratio calculation const imgWidthInPdf = pdfWidth - 80; // 40pt margin on each side const imgHeightInPdf = imgWidthInPdf * ratio; // **FIX**: Correct height calculation let heightLeft = imgHeightInPdf; let position = 0; // Add the first page with a 40pt margin pdf.addImage(imgData, 'PNG', 40, 40, imgWidthInPdf, imgHeightInPdf); heightLeft -= (pdfHeight - 80); // Subtract usable page height // Loop to add new pages if content is longer than one page while (heightLeft > 0) { position -= (pdfHeight - 80); // Move the "view" of the canvas up pdf.addPage(); // Add the same large image but adjust its y-position pdf.addImage(imgData, 'PNG', 40, position + 40, imgWidthInPdf, imgHeightInPdf); heightLeft -= (pdfHeight - 80); } pdf.save(`${companyName}-employee-handbook.pdf`); downloadPdfBtn.innerHTML = originalButtonText; downloadPdfBtn.disabled = false; }).catch(err => { console.error("PDF generation failed:", err); downloadPdfBtn.innerHTML = originalButtonText; downloadPdfBtn.disabled = false; alert("Sorry, there was an error generating the PDF."); }); } // --- Event Listeners --- if (nextBtn) nextBtn.addEventListener('click', handleNext); if (prevBtn) prevBtn.addEventListener('click', handlePrev); if (downloadPdfBtn) downloadPdfBtn.addEventListener('click', downloadPdf); // --- Run Initialization --- initialize(); });
Scroll to Top