mirror of
https://github.com/open-webui/open-webui.git
synced 2026-03-22 06:02:06 -05:00
[PR #6156] [MERGED] Feat: Enhance PDF Downloader to Export Chat #8628
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/6156
Author: @noczero
Created: 10/13/2024
Status: ✅ Merged
Merged: 10/13/2024
Merged by: @tjbck
Base:
dev← Head:add-pdf-generator📝 Commits (1)
c41261efeat: PDF generator to export chat📊 Changes
11 files changed (+428 additions, -56 deletions)
View changed files
📝
backend/open_webui/apps/webui/models/chats.py(+3 -0)📝
backend/open_webui/apps/webui/routers/utils.py(+6 -56)➕
backend/open_webui/static/assets/pdf-style.css(+283 -0)➖
backend/open_webui/static/fonts/NotoSans-Bold.ttf(+0 -0)➖
backend/open_webui/static/fonts/NotoSans-Italic.ttf(+0 -0)➖
backend/open_webui/static/fonts/NotoSans-Regular.ttf(+0 -0)➖
backend/open_webui/static/fonts/NotoSansJP-Regular.ttf(+0 -0)➖
backend/open_webui/static/fonts/NotoSansKR-Regular.ttf(+0 -0)➖
backend/open_webui/static/fonts/NotoSansSC-Regular.ttf(+0 -0)➕
backend/open_webui/utils/pdf_generator.py(+134 -0)📝
backend/requirements.txt(+2 -0)📄 Description
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.
Before submitting, make sure you've checked the following:
devbranch.Changelog Entry
Description
This pull request introduces a new feature that enhances the PDF export functionality in the backend.
The enhancement includes the ability to render markdown-formatted chat messages in the exported PDF. '
This change addresses the limitation where markdown elements such as tables, headings, lists, and styles were previously rendered as raw text in the PDF.
Added
PDFGeneratorclass inbackend/open_webui/utils/pdf_generator.pythat handles the conversion of markdown-formatted chat messages into a styled PDF.pdf-style.csslocated atbackend/open_webui/static/assets/pdf-style.cssto define styles for various markdown elements when rendering them in the PDF.backend/requirements.txt:xhtml2pdf==0.2.16for converting HTML to PDF.pymdown-extensions==10.11.2for enhanced markdown processing.Changed
backend/open_webui/apps/webui/routers/utils.pyto utilize the newPDFGeneratorclass for creating PDFs from chat messages.ChatTitleMessagesFormschema object which invoke inPDFGeneratorandutilsroute.Deprecated
Removed
NotoSans-Bold.ttfNotoSans-Italic.ttfNotoSans-Regular.ttfNotoSansJP-Regular.ttfNotoSansKR-Regular.ttfNotoSansSC-Regular.ttfFixed
Security
Breaking Changes
Additional Information
xhtml2pdflibrary was chosen despite known issues with list rendering, as it provides a robust solution for HTML to PDF conversion. Future updates may address these issues as the library evolves.pymdown-extensionsallows for extended markdown capabilities, making the chat export feature more versatile and powerful.it requires an additional step to install the wkhtmltopdf binary package, beyond just a simple pip install.
Screenshots or Videos
Before

After

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.