Privacy Policy Key Clause Generator
Email for privacy-related inquiries.
Review your generated clauses below. Go back to any tab to make edits.
Click "Next" or "Previous" to refresh this preview.
If you have any questions about this Privacy Policy, please contact us at: ${escapeHTML(email)}
`; summaryPreview.innerHTML = html; }; const getTxtContent = () => { const tempDiv = document.createElement('div'); tempDiv.innerHTML = summaryPreview.innerHTML; // Convert H3 to plain text with underlines tempDiv.querySelectorAll('h3').forEach(h3 => { const underline = '-'.repeat(h3.textContent.length); h3.textContent = `\n${h3.textContent.toUpperCase()}\n${underline}\n`; }); // Convert LI to plain text with bullets tempDiv.querySelectorAll('li').forEach(li => { li.textContent = ` * ${li.textContent}\n`; }); // Convert P to plain text tempDiv.querySelectorAll('p').forEach(p => { p.textContent = `${p.textContent}\n\n`; }); return tempDiv.textContent.replace(/(\n\s*){3,}/g, '\n\n').trim(); // Clean up extra newlines }; const downloadTxt = () => { const txtContent = getTxtContent(); const blob = new Blob([txtContent], { type: 'text/plain;charset=utf-8' }); const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = 'privacy_policy_clauses.txt'; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(a.href); }; const downloadPDF = () => { if (typeof window.jspdf === 'undefined' || typeof window.jspdf.jsPDF === 'undefined') { alert('Error: jsPDF library not loaded.'); return; } const { jsPDF } = window.jspdf; const doc = new jsPDF('p', 'mm', 'a4'); const margin = 20; const pageWidth = doc.internal.pageSize.getWidth(); const usableWidth = pageWidth - (margin * 2); let yPos = 25; // Start position const addWrappedText = (text, options = {}) => { const { font = 'helvetica', style = 'normal', size = 11, isH3 = false, isBullet = false } = options; doc.setFont(font, style); doc.setFontSize(size); let textToSplit = text; let textMargin = margin; let textWidth = usableWidth; if (isH3) { yPos += 5; // Extra space before H3 doc.setFont(font, 'bold'); doc.setFontSize(14); doc.setTextColor(0, 123, 255); } else { doc.setTextColor(52, 73, 94); } if (isBullet) { textMargin += 5; textWidth -= 5; textToSplit = `• ${text}`; } const splitText = doc.splitTextToSize(textToSplit, textWidth); if (yPos + (splitText.length * 6) > 270) { // Check for page break (6mm per line) doc.addPage(); yPos = 20; } doc.text(splitText, textMargin, yPos); yPos += (splitText.length * 6); // 6mm per line yPos += (isH3 ? 3 : 2); // buffer if (isH3) { // Add underline doc.setDrawColor(222, 226, 230); // light grey doc.line(margin, yPos - 1, pageWidth - margin, yPos - 1); yPos += 3; } }; // --- Build PDF Document --- doc.setFont('helvetica', 'bold'); doc.setFontSize(18); doc.setTextColor(44, 62, 80); doc.text("Privacy Policy - Key Clauses", pageWidth / 2, 15, { align: 'center' }); const tempDiv = document.createElement('div'); tempDiv.innerHTML = summaryPreview.innerHTML; tempDiv.childNodes.forEach(node => { if (node.nodeName === 'H3') { addWrappedText(node.textContent, { isH3: true }); } else if (node.nodeName === 'P') { addWrappedText(node.textContent, {}); } else if (node.nodeName === 'UL') { node.querySelectorAll('li').forEach(li => { addWrappedText(li.textContent, { isBullet: true }); }); } }); doc.save('privacy_policy_clauses.pdf'); }; // --- Event Listeners --- // Tab Buttons tabButtons.forEach((btn, index) => { btn.addEventListener('click', () => showTab(index + 1)); }); // Next/Prev Navigation nextBtn.addEventListener('click', () => showTab(currentTab + 1)); prevBtn.addEventListener('click', () => showTab(currentTab - 1)); // Tab 5 Actions downloadPdfBtn.addEventListener('click', downloadPDF); downloadTxtBtn.addEventListener('click', downloadTxt); // --- Initialization --- showTab(1); // Set initial state });