${entity.description}
${entity.symbols && entity.symbols.length > 0 ? `
Key Symbols
${entity.symbols.map(s => `- ${s}
`).join('')}
` : ''}
${familyHTML ? `
Family
${familyHTML}` : ''}
${entity.key_myths && entity.key_myths.length > 0 ? `
Key Myths & Stories
${entity.key_myths.map(m => `- ${m}
`).join('')}
` : ''}
`;
detailArea.style.display = 'block';
document.getElementById('agrmi_downloadPdfButton').style.display = 'block';
detailArea.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
// --- PDF Generation ---
function agrmi_getPDFContent(entityId) {
const entity = agrmi_mythologyData.find(item => item.id === entityId);
if (!entity) return [{ type: 'text', content: "Entity information not found.", size: 12 }];
let content = [];
content.push({ type: 'heading', text: `${entity.name_greek} / ${entity.name_roman}`, size: 18 });
content.push({ type: 'text', text: `Category: ${entity.category.join(', ')}`, size: 10 });
content.push({ type: 'text', text: `Domain/Role: ${entity.domain}`, size: 10 });
content.push({ type: 'spacer', height: 5 });
content.push({ type: 'heading', text: "Description", size: 14 });
content.push({ type: 'text', text: entity.description, size: 10 });
content.push({ type: 'spacer', height: 5 });
if (entity.symbols && entity.symbols.length > 0) {
content.push({ type: 'heading', text: "Key Symbols", size: 14 });
entity.symbols.forEach(s => content.push({ type: 'listItem', text: s, size: 10 }));
content.push({ type: 'spacer', height: 5 });
}
if (entity.family && Object.keys(entity.family).length > 0) {
content.push({ type: 'heading', text: "Family", size: 14 });
if(entity.family.parents) content.push({ type: 'text', text: `Parents: ${entity.family.parents}`, size: 10 });
if(entity.family.spouse) content.push({ type: 'text', text: `Spouse(s): ${entity.family.spouse}`, size: 10 });
if(entity.family.siblings) content.push({ type: 'text', text: `Siblings: ${entity.family.siblings}`, size: 10 });
if(entity.family.children) content.push({ type: 'text', text: `Children: ${entity.family.children}`, size: 10 });
content.push({ type: 'spacer', height: 5 });
}
if (entity.key_myths && entity.key_myths.length > 0) {
content.push({ type: 'heading', text: "Key Myths & Stories", size: 14 });
entity.key_myths.forEach(m => content.push({ type: 'listItem', text: m, size: 10 }));
}
content.push({ type: 'spacer', height: 5 });
content.push({ type: 'text', text: `Image Reference: ${entity.image_placeholder || 'N/A'}`, size: 9, style: 'italic' });
return content;
}
function agrmi_downloadPDF() {
if (!agrmi_currentEntityId) {
alert("Please select a mythological entity first.");
return;
}
if (typeof window.jspdf === 'undefined' || typeof window.jspdf.jsPDF === 'undefined') {
alert('PDF library (jsPDF) is not loaded. Check internet connection.'); return;
}
const { jsPDF: JSPDF } = window.jspdf;
const doc = new JSPDF();
let yPos = 15;
const leftMargin = 15;
const contentWidth = doc.internal.pageSize.getWidth() - (leftMargin * 2);
const entity = agrmi_mythologyData.find(item => item.id === agrmi_currentEntityId);
const pdfContent = agrmi_getPDFContent(agrmi_currentEntityId);
pdfContent.forEach(item => {
if (yPos > 270 && item.type !== 'spacer') { // Basic page break, avoid for simple spacer
doc.addPage();
yPos = 15;
}
switch(item.type) {
case 'heading':
doc.setFontSize(item.size);
doc.setFont(undefined, 'bold');
const headingLines = doc.splitTextToSize(item.text, contentWidth);
doc.text(headingLines, leftMargin, yPos);
yPos += (headingLines.length * (item.size * 0.35)) + (item.size * 0.2);
break;
case 'text':
doc.setFontSize(item.size);
doc.setFont(undefined, item.style || 'normal');
const textLines = doc.splitTextToSize(item.text, contentWidth);
doc.text(textLines, leftMargin, yPos);
yPos += (textLines.length * (item.size * 0.35)) + 2;
break;
case 'listItem':
doc.setFontSize(item.size);
doc.setFont(undefined, 'normal');
const itemLines = doc.splitTextToSize(`• ${item.text}`, contentWidth - 5);
doc.text(itemLines, leftMargin + 5, yPos);
yPos += (itemLines.length * (item.size * 0.35)) + 1;
break;
case 'spacer':
yPos += item.height;
break;
}
});
doc.save(`${entity.name_greek.toLowerCase().replace(/\s+/g, '_')}_mythology_info.pdf`);
}