Error in Export to PDF for Mermaid diagrams

What I’m trying to do

I am trying to export a md page that contains a code block for mermaid markdown and I am getting the following error:

app.js:1 TypeError: Cannot read properties of null (reading 'getBoundingClientRect')
    at addHtmlSpan (mermaid.min.js:396:388)
    at createText (mermaid.min.js:396:2401)
    at labelHelper (mermaid.min.js:396:3938)
    at question (mermaid.min.js:397:34004)
    at insertNode (mermaid.min.js:452:10128)
    at mermaid.min.js:455:751
    at Array.map (<anonymous>)
    at recursiveRender (mermaid.min.js:452:88318)
    at Object.render (mermaid.min.js:455:4059)
    at render (mermaid.min.js:455:4543)

I have tried in a vault with no plugins and no custom css snippets.

I tried another computer as well and it gets a different error:
Error parsing Mermaid diagram! Cannot read properties of undefined (reading 'getBBox')

Both are on Obsidian versions 1.9.7. MacOS

Obsidian editor can render the diagram properly, its only having issues when exporting. I have tried with different diagrams and same result. As a test, I created a very basic diagram (below) which it’s still failing on.

graph TD
    A[Start] --> B[Do something]
    B --> C{Decision?}
    C -->|Yes| D[Do the yes path]
    C -->|No| E[Do the no path]
    D --> F[End]
    E --> F

SYSTEM INFO:
Obsidian version: v1.9.7
Installer version: v1.6.5
Operating system: Darwin Kernel Version 24.6.0: Mon Jul 14 11:29:54 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T8122 24.6.0
Login status: logged in
Language: en
Catalyst license: insider
Insider build toggle: on

Things I have tried

Using Pandoc plugin, using Obsidian export to pdf, tried different vaults

9 Likes

Same issue with 1.9.10:

Error parsing Mermaid diagram!
Cannot read properties of null (reading 'getBoundingClientRect')

mermaid chart displays correctly.

2 Likes

I’m also experiencing this issue on Obsidian v1.9.10.

Instead of drawing the diagram in the pdf, it prints the following.

Error parsing Mermaid diagram!
Cannot read properties of null (reading 'getBoundingClientRect')
2 Likes

I’m encounting same issue.
Obsidian cannot render mermaid diagram when exporting PDF.
My Obsidian’s version is v1.19.10.
I don’t sure that this issue occured anew on latest version?

Encountered sample problem with exporting a note with mermaid diagram.

same for me. It also happens if you open a note in a new window. The diagram then renders in the main window, but not in the new one, showing the same error when exporting to PDF.

Obsidian Version: 1.9.10

Moved to bug reports and renamed.

4 Likes

the same in 1.9.12

1 Like

Same error here using Windows. Everything fully updated. Community Plugs turned off for testing (I only have two and they are up-to-date and there were no issues previously).

Checking my previous work, I found two exported PDFs I created on Aug 4 and Aug 11 this month (posting this on Aug 27). Both have working mermaid diagrams in them. Trying them again, both fail to export to a PDF.

I put the mermaid sections in a new Markdown document as a test.

Test 1: CurXecute Vulnerability Diagram

sequenceDiagram
    participant Attacker
    participant External Service (Slack/GitHub)
    participant Cursor IDE
    participant Local System
    
    Attacker->>External Service (Slack/GitHub): Posts malicious prompt injection
    External Service (Slack/GitHub)->>Cursor IDE: MCP server fetches untrusted data
    Cursor IDE->>Cursor IDE: AI processes malicious prompt
    Cursor IDE->>Local System: Automatically rewrites ~/.cursor/mcp.json
    Local System->>Local System: Executes attacker commands with dev privileges
    Local System->>Attacker: Provides remote access/data theft opportunity

Test 2: WinRAR Vulnerability Diagram

sequenceDiagram
    participant Attacker
    participant Victim User
    participant WinRAR ≤7.12
    participant Windows System
    
    Attacker->>Victim User: Phishing email with "resume.rar"
    Victim User->>WinRAR ≤7.12: Opens malicious archive
    WinRAR ≤7.12->>Windows System: Extracts files using ADS path traversal
    Windows System->>Windows System: Malicious DLL placed in Startup folder
    Windows System->>Attacker: Backdoor establishes connection

They both generate the same as before with no errors in Obsidian.

The exported PDF shows this:
Test 1: CurXecute Vulnerability Diagram
Error parsing Mermaid diagram!
Cannot read properties of null (reading ‘getBBox’)
Test 2: WinRAR Vulnerability Diagram
Error parsing Mermaid diagram!
Cannot read properties of null (reading ‘getBBox’)

Reviewing the changes to my system since then:

  • Updated to Windows 11 from Win10
    • While this could be an issue, the OP is using a Linux flavor and getting the same error, so doubtful.
  • Updated Obsidian
  • Turned off previously working community plugins for testing

下载一个插件,better export pdf,临时解决下这个问题,等官方修复
Download a plugin, better export pdf, to temporarily solve this problem until the official fix is available

1 Like

I downgraded to 1.8.10 to get this working again, following these steps: Obsidian Versions -How to go back?

1 Like

Same here, v.1.9.12

Me too, using better export pdf does work but the style of the graphs is different (different colors mostly) and also it breaks with my columns plugin and excalidraw renderings are smaller than they should be
Hence i’d really love if this was fixed xD

1 Like

Same here, Version 1.9.12 (Installer 1.8.10)

1 Like

Same here: v.1.9.12 (Installer 1.9.10). With only unrelated (I think) community plugins: Linkify and Custom File Explorer sorting.

1 Like

Still the case on on v1.9.12, in a sandbox vault.

1 Like

Same issue here
Version 1.9.12 (Installer 1.8.10)

1 Like

Same issue in version 1.9.14. Installer v1.6.7.

Another same here… To me this is really a deal breaker as I write very long documents in Obsidian, all of which contain tens of mermaid diagrams. They are engineering documents. The style of the formatting is less important, but form and content are key. Things like proper mermaid rendering, page breaks (these are less intuitive in Obsidian, at least for me), are essential.
I can go to pandoc in VS Code but the number of tricks one needs to apply to get to something is large, and the result is not great.

By the way I tried the Better Export PDF plugin and it works well for me, so thanks for the tip @noonehere ! I am using it now and it does the trick well. I will try to work out some font size output options but that is on my, not on the plugin which works great.
Don’t know whether Obsidian resolves this but the plugin does the work too.