l1xnan / obsidian-better-export-pdf

Obsidian PDF export enhancement plugin
MIT License
237 stars 13 forks source link

dom not ready #229

Open Farrukhw opened 3 weeks ago

Farrukhw commented 3 weeks ago

Hi, On one document, although it says, dom not ready, however, it is still able to give me a preview: image and exporting the pdf awesomely.

However, on the other similar document, it is continuously saying "dom not ready" and unable to show any preview and can't Export: image

Please find the .md files with Prefixes "Exporting..." and "Not Exporting..." to test and verify on your side.

Not Exporting, Mean, Median, Mod. The measure of Central Tendency.md Exporting, Variance and Standard Deviations - The Measures of Dispersion.md

l1xnan commented 3 weeks ago

I tested the export in my own Obsidian, and it works fine. This issue is most likely due to a conflict with other plugins. Could you press ctrl+shift+i to open the console and check for any error messages? Additionally, you can enable debug mode to further inspect if there are any errors in the rendering preview modal. image

Farrukhw commented 3 weeks ago

Thanks for the guidance.

Looks like, it has some problem with the Meta data of the .md file. And I'm using only tags in the Meta data. Here are the tags meta data and the error log:

---
tags:
  - mean
  - average
  - median
  - central
  - center
  - mod
  - mode
  - centeral_tendency
---
plugin:obsidian-metatable:2456 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'style')
    at MetatablePlugin.frontmatterProcessor (plugin:obsidian-metatable:2456:12)
    at t.render (app.js:1:1296676)
    at renderMarkdown (plugin:better-export-pdf:20396:43)
    at async ExportConfigModal.renderFiles (plugin:better-export-pdf:20551:20)
    at async ExportConfigModal.appendWebview (plugin:better-export-pdf:20636:7)
    at async eval (plugin:better-export-pdf:20699:7)
frontmatterProcessor @ plugin:obsidian-metatable:2456
t.render @ app.js:1
renderMarkdown @ plugin:better-export-pdf:20396
await in renderMarkdown (async)
window.createEl @ enhance.js:1
Node.createEl @ enhance.js:1
Node.createDiv @ enhance.js:1
onOpen @ plugin:better-export-pdf:20693
e.open @ app.js:1
eval @ plugin:better-export-pdf:21080
e.handleEvent @ app.js:1
click @ app.js:1
apply @ C:\Users\MyUserName\AppData\Local\Obsidian\resources\app.asar\node_modules\@electron\remote\dist\src\renderer\callbacks-registry.js:54
(anonymous) @ C:\Users\MyUserName\AppData\Local\Obsidian\resources\app.asar\node_modules\@electron\remote\dist\src\renderer\remote.js:353
(anonymous) @ C:\Users\MyUserName\AppData\Local\Obsidian\resources\app.asar\node_modules\@electron\remote\dist\src\renderer\remote.js:335
emit @ node:events:517
onMessage @ node:electron/js2c/renderer_init:2

After removing the tags meta data, it started displaying the Preview and printing to pdf.

But...

The file which is being exported to PDF without any issues, also has this Meta data:

---
tags:
  - sigma
  - deviation
  - standard
  - deviation
  - variance
  - dispersion
---

So where is the difference???

PS: I need to have tags in the metadata in order to enhance the search in documents.

Farrukhw commented 3 weeks ago

Finally, I solved this by disabling the plugin obsidian-metatable, as it is referenced in the log.

l1xnan commented 2 weeks ago

The issue seems to be here: https://github.com/arnau/obsidian-metatable/blob/df6b59af4b57e2219ef6c5e8e5bd956356da116e/src/plugin.ts#L88-L89 This plugin has been archived, so there's no way to submit a PR, You can fix and compile it yourself. Additionally, I noticed that the official export feature does not directly throw an error. It's unclear how the official plugin handles exceptions from third-party plugins. If I find out, there might be a better solution.