atom / markdown-preview

📝 Markdown preview in Atom
MIT License
1.23k stars 358 forks source link

PDF export #122

Open alexrussell opened 10 years ago

alexrussell commented 10 years ago

PDF export would be pretty handy. Failing that, the ability to print the Markdown preview (or, in fact any editor) would allow me to save as a PDF. Added bonus is that it'd put less emphasis on exporting the styles in the HTML generated from #70 (at least for me).

travs commented 9 years ago

You can check out my project to export .md to pdf before this is added as an enhancement to markdown-preview. Let me know what you think/any additional functionality you would like :smile:

blackfist commented 9 years ago

+1. Right now I'm using an app called lightPaper to turn markdown into PDF. I would love to be able to do this from Atom and have one less app I gotta worry about.

morberg commented 9 years ago

+1 for printing. For generating PDF @travs markdown-pdf works very well and even uses the styles from markdown-preview.

burnalting commented 9 years ago

all, I am struggling to get @travs markdown-pdf to work. I have the latest atom (0.174.0) on a patched Windows 8.1 workstation and I have markdown-pdf (1.3.0). I have the simplest of .md files

This is a first level heading

This is a second level heading

and markdown-preview displays it correctly, but I can get nothing from C whilst the cursor is within the markdown document display. Do I need something else running on Windows for this to work or do I need to configure more elements of atom?

travs commented 9 years ago

@burnalting Raise an issue on the repo and let's try and solve it!

burnalting commented 9 years ago

Hi tavs,

I just installed atom on a clean fedora 21 and it works. I needed to ensure a markdown-preview had rendered the .md file, but the C resulted in a valid pdf.

I can operate in fedora 21 but I will raise the issue against a Windows 8.1 system

burnalting commented 9 years ago

Hi Travs,

Please excuse my stupidity. On my windows system I had left .pdf files generated by another tool (on a cross mounted Linux system). When nothing appeared to have happened when I pressed C, I assumed an error and didn't look at the file.

My hint was when I attempted to turn a markdown file into pdf on my Fedora 21 box ... it complained that I couldn't write to the directory where the .md file lived.

Perhaps you can update the documentation for your (excellent) package by saying, something to the effect, "Position your mouse/cursor over your .md editing pane, then press C. At this point check the directory where your .md file resides and you should find a pdf of the same file name base. Note it may take some seconds".

The reason for saying and excellent package is that I have been looking for a markdown to pdf process that will scale the .png files I have in my .md file. Yours (perhaps in concert with the markdown-preview code), does the scaling.

Apologies for my failure to understand my base problem.

But a big thank you for you package

Sincerely Burn

travs commented 9 years ago

@burnalting No sweat man. Yeah the docs haven't been updated in a while, so I'll jump on that and make it more clear.

Thanks for the compliment as well! :smile:

cakebake commented 9 years ago

Added a new context menu to cakebake/markdown-themeable-pdf for context menu "Save As PDF" in markdown-preview pane.

UPDATE: Currently it does not work on all systems. CTRL-SHIFT-P -> Window: Reload after Package Update works.

save-as-pdf

benogle commented 8 years ago

Note that there are printing APIs in electron now: http://electron.atom.io/docs/v0.33.0/api/web-contents/#webcontents-print-options

Though might be tricky to just print the contents of the tab with all the correct styles (not the entire UI)

alexrussell commented 8 years ago

@cakebake thanks for the heads-up on your package. I have installed it and will give it a test soon. Looks to be exactly what I want. And the bonus is (or at least seems to be) I can style the HTML how I want for the PDF and have it completely different to the HTML preview in Atom, which means I don't have to worry about the weird uses-your-theme issues with markdown-preview.

The only thing I'm slightly concerned about is that it appears to generate HTML differently to how markdown-preview does, so I could well find that I make the perfect document in Atom and then come to convert it to PDF and certain bits are wrong (I'm obviously thinking about advanced stuff here like tables, HTML, GFM, etc.). Still, that remains to be seen - the fact that you developed this for developers writing documentation sounds ideal as that's what I would use it for.

cakebake commented 8 years ago

@benogle The API is quite simple and effective. Unfortunately, I had problems to realize a header and footer. It is currently not available for me.

@alexrussell Yes, the package renders the Markdown autonomous and independent of the current atom theme. If you have problems with your documents and I can improve the package, feel free to open an Issue in the markdown-themeable-pdf repo.