Rental Lease Agreement Generator

Rental Lease Agreement Generator

Residential Lease Agreement Generator

Review the draft Lease Agreement below. This is a simplified template and should be reviewed by legal counsel before signing.

${utilitiesClause}

5. Pet Policy

${petClause}

6. Signatures

Landlord Signature

Tenant Signature

`; } function rlag_renderDashboard(targetDiv = rlag_dashboardOutput, isPDF = false) { if (!targetDiv) return; const agreementHTML = rlag_generateAgreementText(rlag_data); targetDiv.innerHTML = agreementHTML; } function rlag_renderPdfClone() { rlag_pdfRenderClone.innerHTML = `
${rlag_generateAgreementText(rlag_data)}
`; } /** * Generates and downloads a PDF of the agreement */ async function rlag_downloadPDF() { if (!rlag_data.address || !rlag_data.tenant) { alert("Please enter the property address and tenant name before downloading."); return; } if (typeof jspdf === 'undefined' || typeof html2canvas === 'undefined') { alert("Error: PDF libraries failed to load."); return; } rlag_renderPdfClone(); const { jsPDF } = window.jspdf; try { const contentDiv = rlag_pdfRenderClone.querySelector('.pdf-content'); if (!contentDiv) return; const canvas = await html2canvas(contentDiv, { scale: 1.5, useCORS: true, windowWidth: contentDiv.scrollWidth, windowHeight: contentDiv.scrollHeight }); const imgData = canvas.toDataURL('image/png'); const imgProps = { width: canvas.width, height: canvas.height }; const pdf = new jsPDF({ orientation: 'p', unit: 'pt', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const margin = 40; const contentWidth = pdfWidth - (margin * 2); const contentHeight = (contentWidth * imgProps.height) / imgProps.width; let heightLeft = contentHeight; let position = 0; pdf.addImage(imgData, 'PNG', margin, position + margin, contentWidth, contentHeight); heightLeft -= (pdfHeight - margin * 2); while (heightLeft > 0) { position -= (pdfHeight - margin * 2); pdf.addPage(); pdf.addImage(imgData, 'PNG', margin, position + margin, contentWidth, contentHeight); heightLeft -= (pdfHeight - margin * 2); } const safeName = (rlag_data.tenant || 'lease_agreement').replace(/[^a-z0-9]/gi, '_').toLowerCase(); pdf.save(`${safeName}_Lease_Agreement.pdf`); } catch (error) { console.error("PDF generation failed:", error); alert("An error occurred while generating the PDF."); } } // --- EVENT LISTENERS --- // Tab link clicks rlag_tabLinks.forEach((link, index) => { link.addEventListener('click', () => rlag_switchTab(index)); }); // Next/Prev button clicks if (rlag_prevButton) { rlag_prevButton.addEventListener('click', () => { if (rlag_currentTab > 0) rlag_switchTab(rlag_currentTab - 1); }); } if (rlag_nextButton) { rlag_nextButton.addEventListener('click', () => { if (rlag_currentTab === rlag_tabLinks.length - 1) { rlag_updateDataFromConfig(); rlag_switchTab(0); } else { if (rlag_currentTab < rlag_tabLinks.length - 1) rlag_switchTab(rlag_currentTab + 1); } }); } // PDF download if (rlag_downloadPdfButton) { rlag_downloadPdfButton.addEventListener('click', rlag_downloadPDF); } // --- INITIALIZATION --- rlag_renderConfig(); rlag_renderDashboard(); // Set initial tab state rlag_tabPanes.forEach((pane, index) => { pane.classList.toggle('hidden', index !== 0); pane.classList.toggle('rlag-active', index === 0); }); rlag_tabLinks.forEach((link, index) => { TAB_CLASSES.active.forEach(cls => link.classList.remove(cls)); TAB_CLASSES.inactive.forEach(cls => link.classList.remove(cls)); if (index === 0) { TAB_CLASSES.active.forEach(cls => link.classList.add(cls)); } else { TAB_CLASSES.inactive.forEach(cls => link.classList.add(cls)); } }); });
Scroll to Top