artisticat1 / obsidian-tikzjax

Render LaTeX and TikZ diagrams in your notes
MIT License
395 stars 23 forks source link

Export to PDF not always drawing #45

Open Anatoly03 opened 1 year ago

Anatoly03 commented 1 year ago

There is always buggy and random behavior with multiple tikz pictures and while displayed in the editing + reading view they are not always display in pdf export.

Anatoly03 commented 1 year ago
Screenshot 2023-07-11 at 16 51 44 Screenshot 2023-07-11 at 21 49 56

(That's how the PDF looks like, sometimes it won't render at all, you might be missing an 'await' somewhere)

FegDotExe commented 1 year ago

I have a similar problem, but in my case the pdf does not even render the "loading circle" image; usually, the first 3 or 4 images get loaded and drawn to the pdf, and then what I get is just nothing; for example, in the following image we can see that the very first elements are indeed being drawn: image.


Nonetheless, there always is a point after which the images stop being loaded; here's a comparison between the live preview (first image) and the exported pdf (second image): image image

Anatoly03 commented 1 year ago

@artisticat1 Any updates?

FegDotExe commented 1 year ago

I have an update regarding some experiments I've been making in order to try and pinpoint where the problem is;

Suspecting that this export issue could be related to optimization procedures (e.g. tikz elements not being loaded and thus drawn on the pdf unless they are in view), I tried exporting the document while viewing only the very last element of the document, but the result I got was the exact same as the pdf produced by exporting while viewing the top of the document. At the moment I suspect that the problem might reside in the fact that this plugin seems to have a script as its markdownCodeBlockProcessor, and I think that same script might be the one causing trouble (e.g. not being able to load elements in time thus leading to an empty export or something like this).

Sadly, I'm very unexperienced in js, ts and obsidian plugin developement in general, so I can't really do much else than speculate.

Still hope this can be of help for someone else who's maybe more skilled than me :)

mayurankv commented 7 months ago

Your last conclusions make sense, I wonder if it's possible to set a timer on export by printing which elapses after a safe amount of time and thus is rendered. Alternatively a better way I realise would be rather than rendering the image, embedding the cached image. This would mean no rendering is needed and you can write logic to apply to the codeblock only on printing. Having said this, I can't tell whether images are cached anymore, if so where are they cached and how?

Guilhermwn commented 6 months ago

I am having this exact same problem, i drew some circuits using the plugin to my document and was expecting to export it to print because i was doing some exercises, but when exporting the pdf, the majority of the diagrams didn't load at all, some loaded and got on the pdf but not all of them

image

Here it shows in left the note and on the right is the pdf, this first diagram did export on the diagram but some diagrams more below on the document didn't

image

Here you can see that this new diagram didn't even got exported.

When i first saw this plugin i felt it was a given to appear to me because it was my first exercise drawing circuits like this, and wanted to include this circuits o my notes in obsidian, and through this plugin it was possible, i'm very grateful, but i would appreciate even more if you could solve this issue.

Thank you so much for your work

Uchiha-Senju commented 5 months ago

@artisticat1 Could this be hot-fixed with a command that exports an alternate version of the file with the SVG files hard-linked in the document?

a-nickerson commented 4 months ago

Was having this problem as well. The first graphic in my notes would export in the pdf but not the second. Switching to light mode and exporting to pdf worked.

Guilhermwn commented 4 months ago

Was having this problem as well. The first graphic in my notes would export in the pdf but not the second. Switching to light mode and exporting to pdf worked.

No way, never tried changing to light mode, and after reading your comment it worked on mine too. Thank you.

It's not the best way to solve the problem, because you have to add extra steps to the pdf export to work, if your theme is always dark like mine, but its seems the problem is around the dark mode.