add:修改使用reportlab完成md转pdf

This commit is contained in:
2026-01-15 23:45:46 +08:00
parent cecc8c65be
commit 0cc1a9484e
7 changed files with 436 additions and 299 deletions

View File

@@ -2734,11 +2734,17 @@ async def api_pdf_convert(
# Return PDF file
if download:
from fastapi.responses import StreamingResponse
import urllib.parse
# 处理中文文件名 - 使用 URL 编码确保只包含 ASCII 字符
# 先将中文文件名进行百分比编码
safe_filename = urllib.parse.quote(output_filename, safe='')
return StreamingResponse(
io.BytesIO(pdf_bytes),
media_type="application/pdf",
headers={
"Content-Disposition": f"attachment; filename=\"{output_filename}\""
"Content-Disposition": f"attachment; filename={safe_filename}"
}
)
else: