[Feature]: Export to PDF
marcus-k opened this issue · 11 comments
Description
In a regular Jupyter Notebook, the notebook is able to be exported as a PDF or HTML file. See the export option below.
It would be great to have this feature available in IDL notebooks as well!
Why it Matters
Sharing the IDL notebook with those who want to see it is much easier via the exported PDF file rather than trying to share the notebook directly. Often the people I share it to do not have IDL installed or available.
Suggested Behavior
I imagine this would work in the same fashion as the Jupyter Notebook version where the option is added to the top ribbon menu.
Alternate Behavior
No response
Hey Marcus,
This is on our list and we had a feeling it would be requested!
There's a couple of libraries that I think we can potentially use to do this, and I don't expect it to be too difficult to get together (depending on if the libraries have OS-specific executables or not).
For what gets exported, I'm guessing you would want images included as well? We do have some more advanced features that can be embedded (like maps and animations), so we will have to probably exclude some of those for now.
-Zach
Good to hear from you again! Having the images be included would indeed be preferable. Creating plots and showing them with the code is one of my main use cases.
I have been poking at this a bit - the Markdown is pretty easy to create and to embed images. Unfortunately, some of the libraries don't seem to be the friendliest with our developer environment to create the PDF.
How would you feel about using a 3rd party VSCode extension to do the actual printing? Basically the workflow would be:
- Open a notebook
- Have a magic "Print" button somewhere
- We convert to Markdown
- Use "Markdown PDF" extension to convert to PDF
- If you didn't have it installed, we would prompt you at the start of the process to install
- Enjoy your PDF!
Attached is a sample PDF from one of the ENVI notebooks with a few images embedded.
If you want, I can get a preview of this feature in the next release (within the next week or so) and you can try it out to let me know what you think. It won't be 100% "official" but would maybe be a good place to start.
I think this would be a good enough solution for the time being. I was not aware such a process worked for notebooks. I am interested to see how it turns out.
Here's a little video to show what it will do. There's two places you can find the PDF button: the top right of a notebook and our sidebar.
If you don't have the extension installed, it prompts you and automatically installs it. Then it creates the markdown, PDF, and pops open a file explorer window with the generated file.
If this look good to you, I can get this in and should have an update before the end of the week (have to verify it works on Mac too).
pdf-generation.mp4
OK, just published 4.2.0
which has this listed as a preview feature. It should appear in the marketplace pretty soon.
I also added a help doc if you run into any issues getting the other extension installed.
You can find that here: https://github.com/interactive-data-language/vscode-idl/blob/v4.2.0/extension/docs/notebooks/PDF_GENERATION.md
Main thing for me was that, on my Mac, it took a bit for the extension to install chromium for the PDF generation.
Let me know what you think!
Hey Zach, I think this worked great for my use case! It is actually quite good timing as I was hoping to utilize this just tomorrow to demonstrate work to some colleagues. It should prove very helpful.
I just tested out using the PDF exporting and I like the results. There are a couple things you lose though, such as the distinction between input and output cells, however, it is not a major issue since it is pretty easy to tell by context in my cases.
Thanks for the quick update as always!
Great, glad to hear it worked! And it helps being fast when we can use work that other people have already done.
Do you have an example of what you would like the input and output to look like? I can see what we can do for formatting style. We have control over the markdown that gets generated, so we can probably spruce it up a bit if you would like.
In this process, the markdown conversion puts code input and output cells both into standard markdown code environments. When exporting a Jupyter notebook as PDF, we get a clear distinction between input and output cells with the In [ ]:
and Out [ ]:
labels, seen below.
I think something along these lines, just a label for In and Out would be the easiest.
Thanks for sharing! That makes sense. Unfortunately with a first pass at this using Markdown, we are a little limited in what we can do. There's a few more options I can poke at to try and add a little bit of styling to help with readability, but it won't be perfect.
One other thing worth noting: If the people you share notebooks with have VSCode, they can open them without needing IDL. The only time that you are required to have IDL within the extension is when you run a notebook or start a debug session. Otherwise it's free to use!
I think the end-goal for this feature would probably be converting to HTML. As HTML we would also be able to embed outputs and have a similar results-viewing experience (including controls for animations) as notebooks directly within VSCode.
A quick note on this: I'm going to close this issue since we have a first pass. I also added in some styling updates for the outputs that you hopefully noticed!
If there are any other asks or features, we can track as a separate item.
Our next release for the extension is planned for next week once ENVI Deep Learning 3.0 is available.