Exports the interview evaluation report as a professionally formatted PDF document. The PDF includes all questions, answers, scores, feedback, reference answers, and improvement suggestions in a readable format suitable for printing or sharing.
The report must be generated first using the Get Report endpoint before exporting. The PDF export uses the evaluation data from the generated report.
Provide clear error messages and recovery options:
try { await downloadReport(sessionId);} catch (error) { if (error.status === 404) { showError('Session not found. Please check the session ID.'); } else if (error.status === 400) { showError('Report not generated yet. Generating now...'); await generateReport(sessionId); await downloadReport(sessionId); } else { showError('Download failed. Please try again.'); }}
Filename Handling
Handle different filename encodings properly:
function extractFilename(contentDisposition) { // Try UTF-8 encoded filename first let match = contentDisposition.match(/filename\*=UTF-8''(.+)/); if (match) { return decodeURIComponent(match[1]); } // Fallback to standard filename match = contentDisposition.match(/filename="?(.+?)"?$/); return match ? match[1] : 'interview-report.pdf';}
Mobile Compatibility
Handle mobile browsers that may not support direct downloads:
async function downloadReportMobile(sessionId) { const response = await fetch( `/api/interview/sessions/${sessionId}/export` ); const blob = await response.blob(); // For mobile, open in new tab if (isMobile()) { const url = URL.createObjectURL(blob); window.open(url, '_blank'); setTimeout(() => URL.revokeObjectURL(url), 60000); } else { // Desktop: trigger download saveBlob(blob, `report-${sessionId}.pdf`); }}
Professional Formatting: Clean layout with proper typography and spacing
Visual Elements: Charts and graphs for score visualization
Color Coding: Color-coded scores (green for excellent, yellow for adequate, red for needs improvement)
Bilingual Support: Chinese content with proper character encoding
Print Optimization: Formatted for A4 paper size with appropriate margins
Metadata: Embedded PDF metadata including title, author, and creation date
The PDF filename includes Chinese characters (模拟面试报告) followed by the session ID. Browsers that support RFC 5987 encoding will display the Chinese characters correctly.