RE: NOTICE OF LEASE VIOLATION for property at ${propertyAddr.split('
')[0]}
Dear ${tenantName},
This letter serves as a formal notice that you are in violation of the terms of the lease agreement dated ${leaseDate} for the property mentioned above.
Description of Violation(s)
The following lease violations have been observed:
${violationsList}
${additionalDesc ? `
Specific Details:
${additionalDesc}
` : ''}
Required Action
You are hereby required to remedy these violations within ${cureDays} days from the date of this notice. This is known as the "cure period." Remedying the violations means taking all necessary actions to fully comply with the terms of your lease agreement.
Consequences of Non-Compliance
${consequences}
Please address this matter promptly. We trust you will take the necessary steps to resolve these issues and return to compliance with your lease agreement. If you have any questions, please contact us immediately.
Sincerely,
By: _________________________
Name: ${landlordName}
Title: Landlord/Property Manager
`;
const outputContainer = document.getElementById('notice-output-content');
if(outputContainer) outputContainer.innerHTML = finalHTML;
};
const handleDownloadPdf = async () => {
const { jsPDF } = window.jspdf;
const content = document.getElementById('notice-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 margin = 15;
const contentWidth = pdfWidth - (margin * 2);
const imgProps = pdf.getImageProperties(imgData);
const imgHeight = (imgProps.height * contentWidth) / imgProps.width;
let heightLeft = imgHeight;
let position = margin;
pdf.addImage(imgData, 'PNG', margin, position, contentWidth, imgHeight);
heightLeft -= (pdf.internal.pageSize.getHeight() - margin * 2);
while (heightLeft > 0) {
position = heightLeft - imgHeight + margin;
pdf.addPage();
pdf.addImage(imgData, 'PNG', margin, position, contentWidth, imgHeight);
heightLeft -= (pdf.internal.pageSize.getHeight() - margin);
}
pdf.save('Lease_Violation_Notice.pdf');
} 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);
updateNavButtons();
});