Comprehension
${comprehensionScore}%
Correct Answers
Test Details
Passage: ${currentPassageKey}
Date: ${generationDate}
This report was generated by the Speed Reading & Comprehension Test tool.
`;
pdfContainer.innerHTML = pdfContent;
document.body.appendChild(pdfContainer);
window.html2canvas(pdfContainer, { scale: 2 }).then(canvas => {
const imgData = canvas.toDataURL('image/png');
const { jsPDF } = window.jspdf;
const pdf = new jsPDF({ orientation: 'portrait', unit: 'pt', format: 'a4' });
const pdfWidth = pdf.internal.pageSize.getWidth();
const imgWidth = pdfWidth;
const imgHeight = canvas.height * imgWidth / canvas.width;
pdf.addImage(imgData, 'PNG', 0, 0, imgWidth, imgHeight);
pdf.save(`Reading-Test-Results-${name.replace(/\s/g, '_')}.pdf`);
document.body.removeChild(pdfContainer);
});
};
initialize();
});
function switchTab(tabId) {
const testTab = document.getElementById('test-tab');
const resultsTab = document.getElementById('results-tab');
const testBtn = document.getElementById('tab-test-btn');
const resultsBtn = document.getElementById('tab-results-btn');
if (tabId === 'test') {
testTab.style.display = 'block';
resultsTab.style.display = 'none';
testBtn.classList.add('active');
resultsBtn.classList.remove('active');
} else {
testTab.style.display = 'none';
resultsTab.style.display = 'block';
testBtn.classList.remove('active');
resultsBtn.classList.add('active');
resultsBtn.disabled = false;
}
}