Business Ethics Policy Generator

Business Ethics Policy Generator

Customize and generate a formal business ethics and code of conduct policy for your organization.

Company Information & Introduction

${reporting}

`; const finalHTML = `

Business Ethics & Code of Conduct

Company: ${companyName}
Effective Date: ${effectiveDate}

Introduction

${intro}

${sectionsHTML}

Acknowledgement

All employees are required to read, understand, and comply with this Code of Business Ethics and Conduct. Violations of this code may result in disciplinary action, up to and including termination of employment.

`; const outputContainer = document.getElementById('policy-output-content'); if(outputContainer) outputContainer.innerHTML = finalHTML; }; const handleDownloadPdf = async () => { const { jsPDF } = window.jspdf; const content = document.getElementById('policy-output-content'); if (!content) return; const originalButtonText = downloadPdfBtn.innerHTML; downloadPdfBtn.innerHTML = 'Generating...'; downloadPdfBtn.disabled = true; try { const canvas = await html2canvas(content, { scale: 2, useCORS: true, backgroundColor: '#ffffff' }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF('p', 'mm', 'a4'); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const imgProps = pdf.getImageProperties(imgData); const imgHeight = (imgProps.height * pdfWidth) / imgProps.width; let heightLeft = imgHeight; let position = 15; pdf.addImage(imgData, 'PNG', 10, position, pdfWidth - 20, imgHeight); heightLeft -= (pdfHeight - 15); while (heightLeft > 0) { position = heightLeft - imgHeight + 15; pdf.addPage(); pdf.addImage(imgData, 'PNG', 10, position, pdfWidth - 20, imgHeight); heightLeft -= pdfHeight; } const fileName = `${(document.getElementById('company-name').value || 'Company').replace(/\s+/g, '_')}_Ethics_Policy.pdf`; pdf.save(fileName); } catch (error) { console.error("PDF generation failed:", error); } finally { downloadPdfBtn.innerHTML = originalButtonText; downloadPdfBtn.disabled = false; } }; // Event Listeners tabButtons.forEach((btn, i) => btn.addEventListener('click', () => switchTab(i + 1))); prevBtn.addEventListener('click', () => switchTab(currentTab - 1)); nextBtn.addEventListener('click', () => switchTab(currentTab + 1)); downloadPdfBtn.addEventListener('click', handleDownloadPdf); // Initial setup updateNavButtons(); });
Scroll to Top