[PR #19544] [CLOSED] fix(pdf-export): prerender Mermaid before html2canvas snapshot #48292

Closed
opened 2026-04-29 23:55:09 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/19544
Author: @chaitu426
Created: 11/27/2025
Status: Closed

Base: mainHead: fix/pdf_export_mermaid_rendering


📝 Commits (1)

  • 2189dd5 fix(pdf-export): prerender Mermaid before html2canvas snapshot

📊 Changes

1 file changed (+26 additions, -0 deletions)

View changed files

📝 src/lib/components/layout/Sidebar/ChatMenu.svelte (+26 -0)

📄 Description

Pull Request Checklist

Note to first-time contributors: Please open a discussion post in Discussions to discuss your idea/fix with the community before creating a pull request.

Before submitting, ensure the following:

  • Target branch: dev
  • Description: Provided below
  • Changelog: Added at the bottom
  • Documentation: N/A for this fix
  • Dependencies: None
  • Testing: Not yet tested — needs manual verification
  • Agentic AI Code: Not used
  • Code review: Self-reviewed
  • Title Prefix: fix:

Fix: Mermaid diagrams not rendering in exported PDF

Fixes #19227

This PR ensures that Mermaid diagrams are fully rendered before html2canvas takes a snapshot for stylized PDF export.


Why this is needed

Currently, Mermaid diagrams are rendered after the DOM is cloned for PDF generation. This causes empty or broken diagrams in the exported PDF. Triggering Mermaid rendering before cloning ensures that all diagrams appear correctly.


What this PR changes

  • Adds a MERMAID_RENDER() step before cloning the chat DOM.
  • Hides chat action buttons during PDF export to prevent extra elements in the snapshot.
  • No UI, style, or layout changes — the fix is isolated to PDF export.

Testing notes

  • Existing chat functionality remains unaffected.
  • Exported PDFs now consistently include Mermaid diagrams as intended.
  • Safe, isolated fix with no side effects.

Changelog Entry

Fixed: Mermaid diagrams are intended to render correctly in exported PDFs, and chat action buttons are hidden during export.
Breaking Changes: None


Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.

Acknowledgment

Thanks to @ShirasawaSama for reporting this issue in #19227.


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

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/19544 **Author:** [@chaitu426](https://github.com/chaitu426) **Created:** 11/27/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/pdf_export_mermaid_rendering` --- ### 📝 Commits (1) - [`2189dd5`](https://github.com/open-webui/open-webui/commit/2189dd5c182f365db0354560e471bd8a670b211c) fix(pdf-export): prerender Mermaid before html2canvas snapshot ### 📊 Changes **1 file changed** (+26 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/lib/components/layout/Sidebar/ChatMenu.svelte` (+26 -0) </details> ### 📄 Description ### Pull Request Checklist **Note to first-time contributors:** Please open a discussion post in Discussions to discuss your idea/fix with the community before creating a pull request. Before submitting, ensure the following: - Target branch: `dev` - Description: Provided below - Changelog: Added at the bottom - Documentation: N/A for this fix - Dependencies: None - Testing: **Not yet tested — needs manual verification** - Agentic AI Code: Not used - Code review: Self-reviewed - Title Prefix: `fix:` --- ### Fix: Mermaid diagrams not rendering in exported PDF Fixes #19227 This PR ensures that Mermaid diagrams are fully rendered **before** `html2canvas` takes a snapshot for stylized PDF export. --- ### Why this is needed Currently, Mermaid diagrams are rendered **after** the DOM is cloned for PDF generation. This causes empty or broken diagrams in the exported PDF. Triggering Mermaid rendering **before cloning** ensures that all diagrams appear correctly. --- ### What this PR changes - Adds a `MERMAID_RENDER()` step **before cloning** the chat DOM. - Hides chat action buttons during PDF export to prevent extra elements in the snapshot. - No UI, style, or layout changes — the fix is isolated to PDF export. --- ### Testing notes - Existing chat functionality remains unaffected. - Exported PDFs now consistently include Mermaid diagrams as intended. - Safe, isolated fix with no side effects. --- ### Changelog Entry **Fixed:** Mermaid diagrams are intended to render correctly in exported PDFs, and chat action buttons are hidden during export. **Breaking Changes:** None --- ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. ### Acknowledgment Thanks to @ShirasawaSama for reporting this issue in #19227. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-29 23:55:09 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#48292