`;
const elementToExport = document.createElement('div');
elementToExport.className = 'islce-pdf-export-content';
elementToExport.innerHTML = `
International Student Loan Cost Estimate
` + inputsSummaryHTML + resultsSummaryHTML; const opt = { margin: [0.6, 0.5, 0.6, 0.5], filename: 'International_Student_Loan_Estimate.pdf', image: { type: 'jpeg', quality: 0.95 }, html2canvas: { scale: 2, useCORS: true, logging: false, scrollY: -window.scrollY }, jsPDF: { unit: 'in', format: 'letter', orientation: 'portrait' }, pagebreak: { mode: ['avoid-all', 'css', 'legacy'] } }; if(islce_downloadPdfButtonEl) { islce_downloadPdfButtonEl.disabled = true; islce_downloadPdfButtonEl.textContent = 'Generating...'; } html2pdf().from(elementToExport).set(opt).save().then(() => { if(islce_downloadPdfButtonEl) { islce_downloadPdfButtonEl.disabled = false; islce_downloadPdfButtonEl.textContent = 'Download Estimate as PDF'; } }).catch(err => { console.error("ISLCE: PDF generation error -", err); alert("An error occurred while generating the PDF. Please ensure html2pdf.js is correctly included and try again."); if(islce_downloadPdfButtonEl) { islce_downloadPdfButtonEl.disabled = false; islce_downloadPdfButtonEl.textContent = 'Download Estimate as PDF'; } }); }; // --- Initial Setup --- if (islce_tab_elements.length === 3 && islce_tab_button_elements.length === 3 && islce_loanAmountUSD_El) { islce_showTab(0); } else { console.error("ISLCE Tool FATAL ERROR: Critical HTML elements missing."); const container = document.getElementById('islce-tool-container'); if (container) { container.innerHTML = "Error: Calculator failed to load. Required HTML elements missing.
"; } } });