add:修改使用reportlab完成md转pdf
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user