`;
const pdfTemplate = document.getElementById('pdf-template');
pdfTemplate.innerHTML = reportHtml;
pdfTemplate.classList.remove('invisible');
try {
const { jsPDF } = window.jspdf;
const canvas = await html2canvas(pdfTemplate.querySelector('.pdf-report-container'), { scale: 2 });
const imgData = canvas.toDataURL('image/png');
const pdf = new jsPDF({ orientation: 'p', unit: 'pt', format: 'a4' });
const pdfWidth = pdf.internal.pageSize.getWidth();
const pdfHeight = (canvas.height * pdfWidth) / canvas.width;
pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, pdfHeight);
pdf.save('JSON_to_Markdown_Report.pdf');
} catch (e) {
console.error('PDF Generation Error:', e);
showNotification('Error generating PDF.');
} finally {
downloadPdfBtn.disabled = false;
downloadPdfBtn.textContent = 'Download PDF';
pdfTemplate.classList.add('invisible');
pdfTemplate.innerHTML = '';
}
}
// --- EVENT LISTENERS ---
convertBtn.addEventListener('click', convertJsonToMarkdown);
copyBtn.addEventListener('click', copyMarkdown);
downloadPdfBtn.addEventListener('click', generatePdfReport);
// --- INITIALIZATION ---
// No tabs to initialize
});