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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user