-
-
Notifications
You must be signed in to change notification settings - Fork 147
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
PDF generation #1
Comments
BTW I have some experience with |
Thanks. How would you implement PDF generation using pandoc? |
First step would be to generate a single page output (even HTML would be interesting in itself, e.g. if you want to email the documentation). Pandoc needs an input and a template. The input could be said HTML document, or markdown or what it is you currently generate. The template is in LaTeX. Pandoc would than be required on the path. Creating PDF files through LaTeX is a bit of a pain through, as it depends on texlive which is over 2GB when installed fully. Maybe offer the option to compile through docker? Most developers have that installed nowadays I guess... Some alternatives are possible:
|
I tried pandoc to convert pdoc documentation index.html as well as some other HTML. It didn't work. The latex converters seem picky about everything, including non-ASCII characters and referenced SVG images. There are some indications (jgm/pandoc#1793 (comment)) that alternative engines should be preferred for better results. Engine Pdoc indeed already contains some provisions for printing: Line 353 in e7868e2
Lines 302 to 381 in e7868e2
If we could somehow leverage the common web browsers, some instance of which exists in almost all environments, that'd be great! I was looking into Selenium / WebDriver API and whether it supports printing to file, but it appears this is not the (common) case. I found this Reddit thread, comparing several possible approaches, and of the listed I feel like preferring running Chrome the most. chromium --headless --disable-gpu --print-to-pdf=output.pdf input.html Second to that maybe WeasyPrint, but that has a list of dependencies that may not be so easy to support in all environments (e.g. Windos without a C/C++ compiler). |
I like the chromium route best. How much work would it be to generate a single HTML file? The current index file can become the TOC, the rest chapters, all links internal. |
Currently, every module is rendered and written out separately: Lines 253 to 275 in e7868e2
So not too much, but it would certainly bear generating a new mako template that handles a list of modules and in which all Is ths something you would care to work on? |
Or, probably better yet, adapting existing HTML template. It already handles a list of modules in a way when pdoc is run as Lines 66 to 81 in e7868e2
|
@victorklos I made some progress #20 using markdown and pandoc. If you're still interested, please have a look. |
Great! I will, but earliest this weekend... |
The generated PDF already looks great though! Maybe add some |
It now prints straight to markdown, so any styling would need to be overridden on pandoc/LaTeX level, or a new set of CSS written and included as raw HTML for conversion through intermediate HTML. |
Expected Behavior
A generated pdf document after
pdoc3 --pdf time
.Actual Behavior
Steps to Reproduce
Additional info
The text was updated successfully, but these errors were encountered: