Open yzhang-gh opened 3 years ago
Note that Chrome's print-to-pdf functionality does not always retain working hyperlinks in the output PDF, see here: https://superuser.com/questions/809627/print-webpage-to-pdf-with-working-hyperlinks
Retaining hyperlinks might be a desirable feature of markdown-to-pdf, though.
As far as I know, it works well in general. (The superuser link looks quite outdated.)
Are you aware of https://github.com/yzane/vscode-markdown-pdf?
Yep, I know it from the very beginning. It uses Puppeteer now so it also has the problem that it doesn't generate bookmarks.
Why not consider pandoc
? It works well with bookmarks. Check out this vscode-pandoc. Note that Typora uses pandoc
to export to many formats including epub, rtf, LaTeX, docx, etc. but not PDF and HTML. I guess Typora uses the print API of Electron to export PDF? There is an open source markdown editor similar to Typora called Mark Text which seems to use this API.
Besides, FYI Markdown Extended uses Puppeteer and nbconvert
of Jupyter Notebook uses both pandoc and Puppeteer (provides two versions of PDF export).
pandoc
The PDF is generated by TeX so the layout is totally different. If users want that, they already have vscode-pandoc as you mentioned...
I guess Typora uses the print API of Electron to export PDF? There is an open source markdown editor similar to Typora called Mark Text which seems to use this API.
Mark Text does use the API from Electron. But I guess it doesn't have bookmarks (unlike Typora).
I see what you mean. They say nothing about what Typora uses for its PDF export on their website. Maybe can try WeasyPrint. This one works well with both bookmarks and CJK.
Note that this one directly uses the python library pydyf
to create PDFs and does not require a chromium.
WeasyPrint
Interesting. Adding to the list.
I just wanted to say that I am so happy this is under consideration because I love this extension so much, but what annoys me is having to export everything to HTML, then open the HTML in Firefox, then save the page as a PDF, and in many cases then have to use another program to merge the pdfs together into one file. I just wanted to say that I'm so happy this issue is open and I hope it's progressing well! Thank you for your work, this is a great extension!
hey @yzhang-gh any update about this nice feature?
Hi, any updates here?
It will be really help if pdf can be generated.
One more issue about the markdown-pdf extension is the lack of math formula conversion support.
Although this issue can be fixed by adding following code, but this fix doesnt work in private net.
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: {inlineMath: [['$', '$']]}, messageStyle: "none" });</script>
Any plan to add support?
It would be really nice to install only one extension for markdown rather than lots of different extensions.π
Hi, thank both of you for the interest. As you may already know, (up to now) there is no good API for the PDF related functionality. And different external tools have different issues, any of the solutions not only requires great effort but also is not that satisfactory. It might be a better idea to make improvements to the existing markdown-pdf extension rather than implementing a new one.
Thanks for answering @yzhang-gh, I know what you mean. Thanks for your effort and your work, excellent work!
I guess it is a good idea if you write explicity that this addon does not support PDF (and write which one can do it, if you want) in the README.md section and also is not planned, just for clarify the situation like many people open the issue about this topic.
Have a good developing time!
Updated: 2024-04
Considering the complexity and the foreseeable outcome of the current possible solutions, we may not plan to implement this feature until there are better ways.
Users can use Markdown PDF for this missing feature.
installChromium
cc #270.
install.ts
https://github.com/puppeteer/puppeteer/blob/main/src/node/install.tsHelp wanted
In case anyone knows how Typora (Electron-based) generates bookmarks for headings.
https://www.electronjs.org/docs/api/web-contents#contentsprinttopdfoptions
Found a Python-based TOC generation tool https://github.com/Krasjet/pdf.tocgen