Debt Collection Letter Generator
Create a formal debt collection letter by filling in the details below.
Letter Details
Creditor Information (You)
Debtor Information
Debt Details
Payment Deadline
Modal content goes here.
If you believe this notice has been sent in error or if you would like to discuss a payment plan, please contact us immediately at [Your Phone Number] or [Your Email Address].
Sincerely,
${p('creditorName', 'Your Name / Company Name')}
`; } /** * Updates the live preview pane. */ function updatePreview() { letterPreview.innerHTML = generateLetterHTML(); } /** * Generates and downloads a PDF of the letter. */ function downloadPDF() { const requiredFields = ['creditorName', 'debtorName', 'amountOwed', 'dueDate', 'daysToPay']; const isMissing = requiredFields.some(id => !document.getElementById(id).value); if (isMissing) { showModal('Please fill in all required fields before downloading the PDF.'); return; } const { jsPDF } = window.jspdf; if (typeof jsPDF === 'undefined' || typeof html2canvas === 'undefined') { showModal('Error: PDF generation library failed to load.'); return; } const doc = new jsPDF({ unit: 'pt', format: 'a4' }); const source = letterPreview; const margin = 40; doc.html(source, { x: margin, y: margin, width: 595 - (margin * 2), // A4 width in points minus margins windowWidth: source.scrollWidth, callback: function(doc) { doc.save('Debt-Collection-Letter.pdf'); } }); } // --- Event Listeners --- formInputs.forEach(input => input.addEventListener('input', updatePreview)); downloadPdfBtn.addEventListener('click', downloadPDF); // --- Initial Load --- document.getElementById('dueDate').value = new Date().toISOString().split('T')[0]; updatePreview(); });