Preprocess mathy html with MathJax-node and then use PrinceXML to output PDF.