`).join('');
}
};
// --- PDF Download ---
window.aratsDownloadPDF = function() {
// Ensure preview is up to date
aratsUpdatePreview();
const element = document.getElementById('arats-print-area');
const issueName = document.getElementById('arats-issue-name').value || "Advocacy_Briefing";
document.body.classList.add('arats-generating-pdf');
const opt = {
margin: [0.75, 0.75],
filename: `${issueName.replace(/\s+/g, '_')}_Briefing_Sheet.pdf`,
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { scale: 2, useCORS: true },
jsPDF: { unit: 'in', format: 'letter', orientation: 'portrait' }
};
html2pdf().set(opt).from(element).save().then(() => {
document.body.classList.remove('arats-generating-pdf');
});
};
// Utility: HTML Escape
function escapeHtml(text) {
if (!text) return '';
return text.replace(/[&<>"']/g, function(m) {
switch (m) {
case '&': return '&';
case '<': return '<';
case '>': return '>';
case '"': return '"';
case "'": return ''';
default: return m;
}
});
}
