HTML to Image (or PDF) via Python
I have been looking for a way to export a rendered markdown document to PDF. Unfortunately I have not been able to find a reliable way to do this (there are a lot of dependencies for the libraries I saw and I couldn't find a way to import them successfully. The APIs for web services to convert could potentially solve the issue, but I would prefer to do the conversion on my device and handle the output there).
I decided to try to change my approach because PIL can export to pdf so I was wondering if anyone knew of a way to convert an HTML page to an image that could then be run through PIL to be formatted into a PDF.
Does anyone know how this could be done (or of a better way)?
Yes! Caleb McDaniel has a blog post about using Pandoc via DocVerter to do exactly this. Basically, he wrote a Pythonista script that sends Markdown text on the clipboard to DocVerter, which creates a PDF and saves it to Dropbox, where it can be accessed (or even automatically opened via Goodreader URL scheme).
I don't know the first thing about Python, so I'm not sure if this Pythonista script can be ported over to Editorial. But it would be pretty slick if it could. If you (or others) find a way to make this work, I'd love to hear about it here!
PDF created by PIL is big and not searchable.
DocVerter requires an internet connection.
Peter has more ways.