Note: Pricing reflects peak travel season.
' : ''}$${dest.estimatedFlight.toFixed(0)}
Est. Flight
$${dest.estimatedAccom.toFixed(0)}
/ Night (Accom.)
$${dest.estimatedDaily.toFixed(0)}
/ Day (Spending)
Top Affordable Destinations
${resultsHtml}
`;
downloadBtn.classList.remove('hidden');
}
function downloadPDF() {
const { jsPDF } = window.jspdf;
const pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' });
const contentToPrint = document.getElementById('dashboard-content');
if (!contentToPrint) return;
html2canvas(contentToPrint, { scale: 2, useCORS: true }).then(canvas => {
const imgData = canvas.toDataURL('image/png');
const pdfWidth = pdf.internal.pageSize.getWidth();
const pdfHeight = (canvas.height * pdfWidth) / canvas.width;
let heightLeft = pdfHeight;
let position = 0;
const pageHeight = pdf.internal.pageSize.getHeight();
pdf.addImage(imgData, 'PNG', 10, 10, pdfWidth - 20, pdfHeight > 277 ? 277 : pdfHeight - 20);
heightLeft -= (pageHeight - 20);
while (heightLeft > 0) {
position = -heightLeft - 20;
pdf.addPage();
pdf.addImage(imgData, 'PNG', 10, position, pdfWidth - 20, pdfHeight);
heightLeft -= pageHeight;
}
pdf.save('Affordable-Destinations.pdf');
});
}
