Legal Notice Generator
Create professional legal notices in seconds. Customize the tone and download in multiple formats.
Notice Details
Generated Notice
📄
No Notice Generated
Fill out the form and click “Generate Notice” to create your legal notice.
Notice copied to clipboard!
`], { type: 'application/msword' });
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = 'legal-notice.doc';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
showNotification('Word document downloaded!');
}// Function to download as PDF
function downloadPDF() {
const { jsPDF } = window.jspdf;
const noticeContent = document.getElementById('noticeOutput');
const originalDisplay = noticeContent.style.display;
// Temporarily show content for PDF capture
noticeContent.style.display = 'block';
html2canvas(noticeContent, {
scale: 2,
useCORS: true,
logging: false
}).then(canvas => {
const imgData = canvas.toDataURL('image/png');
const pdf = new jsPDF('p', 'mm', 'a4');
const imgWidth = pdf.internal.pageSize.getWidth();
const imgHeight = canvas.height * imgWidth / canvas.width;
// Add first page
pdf.addImage(imgData, 'PNG', 0, 0, imgWidth, imgHeight);
// Add additional pages if needed
let heightLeft = imgHeight;
let position = 0;
const pageHeight = pdf.internal.pageSize.getHeight();
while (heightLeft > 0) {
position = heightLeft - pageHeight;
pdf.addPage();
pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
heightLeft -= pageHeight;
}
pdf.save('legal-notice.pdf');
// Restore original display state
noticeContent.style.display = originalDisplay;
showNotification('PDF downloaded successfully!');
});
}// Event listeners when DOM is loaded
document.addEventListener('DOMContentLoaded', function() {
// Show/hide custom reason field
document.getElementById('noticeReason').addEventListener('change', function() {
const customReasonContainer = document.getElementById('customReasonContainer');
if (this.value === 'custom') {
customReasonContainer.style.display = 'block';
} else {
customReasonContainer.style.display = 'none';
}
});
// Tone preview selection
document.querySelectorAll('.tone-preview span').forEach(span => {
span.addEventListener('click', function() {
// Remove active class from all
document.querySelectorAll('.tone-preview span').forEach(s => {
s.classList.remove('active');
});
// Add active class to clicked
this.classList.add('active');
// Update dropdown
document.getElementById('tone').value = this.dataset.tone;
});
});
// Generate button
document.getElementById('generateBtn').addEventListener('click', function() {
if (validateForm()) {
const noticeContent = generateLegalNotice();
document.getElementById('noticeOutput').innerHTML = noticeContent;
document.getElementById('outputContainer').style.display = 'block';
document.getElementById('emptyState').style.display = 'none';
// Scroll to output
document.getElementById('outputContainer').scrollIntoView({ behavior: 'smooth' });
}
});
// Reset form button
document.getElementById('resetBtn').addEventListener('click', resetForm);
// Reset output button
document.getElementById('resetOutputBtn').addEventListener('click', resetOutput);
// Print button
document.getElementById('printBtn').addEventListener('click', function() {
window.print();
});
// PDF button
document.getElementById('pdfBtn').addEventListener('click', downloadPDF);
// Word button
document.getElementById('wordBtn').addEventListener('click', downloadWord);
// Copy button
document.getElementById('copyBtn').addEventListener('click', copyToClipboard);
});