astefanutti / decktape

PDF exporter for HTML presentations
MIT License
2.21k stars 177 forks source link

MathJax formulas are not rendered correctly with the HTML-CSS output on Docker #76

Closed JanoschDeurer closed 7 years ago

JanoschDeurer commented 8 years ago

If I try to create a pdf from a reveal.js presentation then all mathjax formulas are replaced by decktape with boxes which makes them unreadable. Am I supposed to somehow load an additional math font or something?

astefanutti commented 8 years ago

@JanoschDeurer you may find some information in #50 and #72. Let me know if that helps.

JanoschDeurer commented 8 years ago

Thanks for the quick response. My description was a bit imprecise so I attached a screenshot this time:

latex

As you can see the formula is not rendered with the wrong spacing or font but with actual boxes around it.

astefanutti commented 8 years ago

Would you be able to produce a minimal sample so that I can reproduce?

JanoschDeurer commented 8 years ago

I produced a minimal example here: https://wobble.ninja/temp/demo-minimal.zip (I couldn't upload it as a comment attachment for some reason, hence the link)

While trying to create an example as small as possible I noticed that the formula must be at least on the 9th page. If you remove one of the previous pages the boxes will go, but the formula will still be rendered incorrectly.

astefanutti commented 7 years ago

Thanks for the minimal example and sorry for the delay.

I've just tried exporting the example with DeckTape 1.0.0 and have been able to produce the following PDF: test.pdf. I've tested it on Mac OS X and Linux, without being able to reproduce your issue.

Note that I've just changed the example to use the latest MathJax lib from their CDN. Besides, could you confirm you use DeckTape version 1.0.0. What OS are you using?

Let me know if I can do anything else.

JanoschDeurer commented 7 years ago

Hey, thanks for the answer. I use the latest docker image, I should have mentioned this before to make reproducing the error easier. My setup is as follows:

I make revealjs available on port 8000 using the following docker image I created: https://hub.docker.com/r/agiled/reveal.js-docker/

I just updated my local version of the container to the latest MathJax from Github, so this should be ok as well.

I execute a script that goes recursively through a given path finds all index.html files and runs your docker image on all these files. I attached the script here: pdfgen.zip, but a simple use of the docker image over http should suffice.

Thank you for your help :)

astefanutti commented 7 years ago

I've been able to reproduce the issue with the following:

$ docker run --rm -v `pwd`:/slides astefanutti/decktape index.html test.pdf --load-pause=20000

There are multiple things:

I've tried changing the MathJax RevealJS extension configuration to use the SVG output, e.g.:

Reveal.initialize({

    math: {
      mathjax: 'https://cdn.mathjax.org/mathjax/latest/MathJax.js',
      config: 'TeX-AMS_SVG'
    },
...

And that fixes the issue. So that can be a potential work-around (in addition to using binaries instead of Docker) in the short term.

I've tried updating the Docker image by installing the fonts-mathjax package, though that does not change the rendering. So it seems that there is an issue with the HTML-CSS output where dynamic fonts downloading does not work.

astefanutti commented 7 years ago

As an additional note, it seems the HTML-CSS output retrieve the font data for the formulas from: https://cdn.mathjax.org/mathjax/latest/jax/output/HTML-CSS/fonts/STIX/fontdata.js?V=2.7.0. It may be that PhantomJS is not capable of taking those fonts into account correctly.

astefanutti commented 7 years ago

Should be fixed in version 2.0.1 that uses headless Chrome. Let me know if you still face this issue.