feat: add PDF export generation via WeasyPrint with branded template

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
chihlasm
2026-03-17 00:28:22 -04:00
parent 2c11917b5a
commit 312024e143
6 changed files with 686 additions and 1 deletions

View File

@@ -391,6 +391,22 @@ async def export_session(
detail="You don't have access to this session"
)
# PDF export — separate path with binary response
if export_options.format == "pdf":
from app.services.export_service import generate_pdf_export
from fastapi.responses import Response
pdf_bytes = await generate_pdf_export(session, export_options, db)
if session.completed_at:
session.exported = True
await db.commit()
return Response(
content=pdf_bytes,
media_type="application/pdf",
headers={"Content-Disposition": f'attachment; filename="session-export-{session_id}.pdf"'},
)
# Generate export based on format
if export_options.format == "markdown":
content = generate_markdown_export(session, export_options)