Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for weasyprint and prince #3909

Merged
merged 2 commits into from
Sep 12, 2017
Merged

Support for weasyprint and prince #3909

merged 2 commits into from
Sep 12, 2017

Conversation

mb21
Copy link
Collaborator

@mb21 mb21 commented Sep 10, 2017

Rename --latex-engine to --pdf-engine and add support for weasyprint and prince, in addition to wkhtmltopdf

closes #3906

Three remarks/TODOs.

  1. In PDF.hs#html2pdf: could we use "program - html2pdf.pdf" to read from stdin instead of using a tempFile? All three HTML-to-PDF-engines support it.

  2. It's still a bit counter-intuitive that you have to specify a writer when not using LaTeX, e.g. see:

     $ pandoc -o output.pdf --pdf-engine=weasyprint
     pdf-engine weasyprint is not compatible with format latex, please use `-t html`
    

    I guess we could change the App.hs#defaultWriterName function to depend on the pdf-engine. Then the only question is: why can't I also use context and pdfroff with --pdf-engine?

  3. TODO: research and implement best approach to math-handling for weasyprint and prince

@mb21 mb21 changed the title Support for weasyprint and prince, in addition to wkhtmltopdf Support for weasyprint and prince Sep 10, 2017
@jgm
Copy link
Owner

jgm commented Sep 10, 2017

Re 1) I'm in favor of using stdin when possible (and also stdout, if we can get the PDF to stdout -- then we wouldn't need any temp files at all).

Re 2) I agree. defaultWriterName for ".pdf" should be sensitive to the pdf-engine selected. Perhaps we should also emit an INFO level log message saying which format had been auto-selected.

and add support for `weasyprint` and `prince`, in addition to `wkhtmltopdf`
closes jgm#3906
@mb21
Copy link
Collaborator Author

mb21 commented Sep 11, 2017

finally done. that was somewhat more elaborate than expected, but hopefully it will be a lot easier to add pdf-engines in the future.

@jgm jgm merged commit c7e3c1e into jgm:master Sep 12, 2017
@mb21 mb21 deleted the pdf-engine branch September 12, 2017 07:05
@iandol
Copy link
Contributor

iandol commented Sep 12, 2017

You also changed --latex-engine-opt to --pdf-engine-opt?

@mb21
Copy link
Collaborator Author

mb21 commented Sep 12, 2017

@iandol jep, arguments specified with --pdf-engine-opt now also get passed to the other pdf-engines...

@iandol
Copy link
Contributor

iandol commented Sep 12, 2017

Can confirm that latest nightly:

pandoc -o Lu.pdf --pdf-engine='prince' --pdf-engine-opt='--page-margin=10mm' Lu.md

Worked as expected. Thank you so much @mb21 for your contribution!

@jgm
Copy link
Owner

jgm commented Sep 12, 2017

I tested --pdf-engine=prince --mathml and got so-so results. Typesetting isn't as good as LaTeX, by any stretch, and the fonts are often missing needed characters. But you can use any font you like.

screen shot 2017-09-12 at 9 00 23 am

@mb21
Copy link
Collaborator Author

mb21 commented Sep 12, 2017

jep, probably the way to do it for now is through generating SVGs... e.g. from print-css.rocks:

Brought to the point: MathML support in all renderers is broken at the moment. Lots of formatting and layout issues with native renderers and renderers based on MathJax (Vivliostyle). It is questionable if MathML will ever work. The only future for MathML is a cross-plattform support for a Javascript based rendering engine like MathJax. However neither PrinceXML nor PDFreactor nor Antennahouse support MathJax. So the only recommendation for using MathML directly: forget it. The only valid option is to convert MathML somehow to LaTeX and then SVG. MathML parts of your input should be replaced with a related SVG.

@linquize
Copy link

Is latex still the default?

@mb21
Copy link
Collaborator Author

mb21 commented Sep 13, 2017

@linquize yes, pdflatex is (for better or worse) still default... (see the updated MANUAL.md)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WeasyPrint for PDF generation?
4 participants