Home vs. Apartment Living Expense Comparison
Home Ownership Expenses (Monthly)
Enter monthly amount, or click 'Annual?' to enter yearly.
Enter monthly amount, or click 'Annual?' to enter yearly.
Apartment Living Expenses (Monthly)
Enter monthly amount, or click 'Annual?' to enter yearly.
E.g., Electricity, Gas (if separate), Internet.
Comparison Summary
Enter your estimated expenses in the 'Home Expenses' and 'Apartment Expenses' tabs. Then, results will be shown here.
A summary of estimated living expenses.
Home Ownership Expenses
| Expense Item | Entered Value (Monthly Equivalent) |
|---|---|
| Total Monthly Home Expenses | ${lscFormatCurrency(results.home.monthly)} |
| Total Annual Home Expenses | ${lscFormatCurrency(results.home.annual)} |
Apartment Living Expenses
| Expense Item | Entered Value (Monthly Equivalent) |
|---|---|
| Total Monthly Apartment Expenses | ${lscFormatCurrency(results.apartment.monthly)} |
| Total Annual Apartment Expenses | ${lscFormatCurrency(results.apartment.annual)} |
Comparison Summary
| Category | Home | Apartment |
|---|---|---|
| Total Monthly Expenses | ${lscFormatCurrency(results.home.monthly)} | ${lscFormatCurrency(results.apartment.monthly)} |
| Total Annual Expenses | ${lscFormatCurrency(results.home.annual)} | ${lscFormatCurrency(results.apartment.annual)} |
| Monthly Difference | ${diffMonthlyText} | |
| Annual Difference | ${diffAnnualText} | |
Generated on: ${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}
`; pdfContentElement.innerHTML = pdfHTML; document.body.appendChild(pdfContentElement); // Must be in DOM for html2canvas try { const canvas = await html2canvas(pdfContentElement, { scale: 2, useCORS: true, backgroundColor: '#ffffff' }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'p', unit: 'pt', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const imgProps = pdf.getImageProperties(imgData); const imgWidth = imgProps.width; const imgHeight = imgProps.height; const ratio = Math.min((pdfWidth - 40) / imgWidth, (pdfHeight - 40) / imgHeight); // -40 for margins const scaledWidth = imgWidth * ratio; const scaledHeight = imgHeight * ratio; const xOffset = (pdfWidth - scaledWidth) / 2; const yOffset = 20; pdf.addImage(imgData, 'PNG', xOffset, yOffset, scaledWidth, scaledHeight); pdf.save('Home_vs_Apartment_Expenses.pdf'); } catch (error) { console.error("Error during PDF generation:", error); alert("An error occurred while generating the PDF."); } finally { document.body.removeChild(pdfContentElement); } }