Use case or problem
While it is possible to export a note in PDF, the export does not take in account the UI theme currently in use (i.e. the Preview’s CSS).
However, such a feature would be easy to implement and extremely useful for producing good-looking and professional documents within minutes.
Proposed solution
The following article suggest a way of generating a PDF using two JS libs:
Mellul, D. (August 2, 2020). Javascript : Convert HTML + CSS to PDF. Print HTML in Seconds. Medium. https://itnext.io/javascript-convert-html-css-to-pdf-print-supported-very-sharp-and-not-blurry-c5ffe441eb5e
In sum, the process is the following:
- Convert the preview’s root HTML node into a canvas.
At a quick glance, this would be.view-content
. - Convert the obtained HTML into a PDF.
This method produces a rasterized (image) PDF.
While this doesn’t allow for text selection, it is sufficient for most uses.
My suggestion is to implement this feature alongside the existing PDF export, thereby providing two export functions, something like:
“Export Markdown to PDF” // Existing export function
“Export Preview to PDF” // Through JSpdf
Related feature requests (optional)
This is somewhat related:
Also related, any feature request pertaining to HTML export.