Skip to content
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

Feature Request: More control of Notebook PDF Export #5199

Open
rickhg12hs opened this issue Aug 24, 2018 · 10 comments
Open

Feature Request: More control of Notebook PDF Export #5199

rickhg12hs opened this issue Aug 24, 2018 · 10 comments

Comments

@rickhg12hs
Copy link

rickhg12hs commented Aug 24, 2018

It would be useful if more control was possible when exporting a notebook as PDF. For example,

  1. Optionally respecting open/closed cells for PDF generation rather than always rendering closed/collapsed cells.
  2. Font selection
  3. Page layout (portrait/landscape, page size, margins, etc.)
  4. And many more options, I'm sure. ... Possibly for the other export formats too.

EDIT: Stream of thought feature additions...

  1. Page rotation, page scaling, 2 columns on each page (Kinda like enscript -2Gr)

If there is an export control/config file somewhere, I wouldn't mind trying to edit it as an interim step.

I'd like to create PDF reports where almost exclusively the markdown and plots are rendered with a bunch of Julia code under the hood (not rendered in the PDF) that generates the plots.

@t-makaro
Copy link

t-makaro commented Aug 24, 2018

The export to pdf is done with nbconvert. In order to change things like fonts, page layout, etc., one needs to create a nbconvert template. This entails using jinja to template LaTeX. To do this in a general manner is quite difficult. Especially for fonts. Unfortunately, I think that something this general is out of sight (but I'm not a jlab dev so...). (I suppose someone could attempt to make a jlab extension that automatically makes templates though that may have it's own complications and restrictions)

It is possible to create your own template with your style preferences and then set the export within jlab to use it. You can see an example of this over at my repo.

For point 1, if jlab uses meta-data to store whether a cell is collapsed then it wouldn't be to hard to implement an nbconvert preprocessor to do this. (We probably don't need a new preprocessor; it may just be a case of using an existing one.)

@t-makaro
Copy link

In terms of reports and not showing the code. Nbconvert is adding a nice shortcut for this from the command line hopefully in the next release. If you want more control over nbconvert you'll have to use the command line interface and friends. If you have more questions about using nbconvert, I'd be happy to assist as I've spent a lot of time working with nbconvert and exporting to PDFs. We could find a way to communicate outside of GitHub or ask a question over in either my repo or in nbconvert

@timkpaine
Copy link
Member

Lantern adds it right under the current export menu, email uses it to email pdf of the notebook.

@rickhg12hs
Copy link
Author

Wow! Awesome stuff!

It'd be cool if there was a selector (or cell magic) to indicate which cells should/shouldn't be rendered.

@t-makaro
Copy link

t-makaro commented Aug 24, 2018

Yes, you can absolutely add new exporters to the menu. It shouldn't be to hard to subclass the pdfexporter to remove collapsed cells be default and/or all code cells (leaving the output). Both of these should even be possible without a custom exporter. It would just require changing the Jupyter config file. We just wouldn't want to add a load of exporters of every possible combination of use cases.

Now that I think about it. It would be possible to click "export to pdf" and have it open a little window with options to enable/disable different preprocessors. That wouldn't let one use different fonts/page sizes, but it would still give a load of options. Extension idea....

@gmoutso
Copy link

gmoutso commented Jun 30, 2020

Is this still open in light of #5015? I am trying to acchieve the --no-input nbconvert option from the jupyterlab "export as" menu.

@gmoutso
Copy link

gmoutso commented Jun 30, 2020

I opened #8629.

@timkpaine
Copy link
Member

referencing this here, adding two "no code" exporters: https://github.com/timkpaine/jupyterlab_nbconvert_nocode

@timkpaine
Copy link
Member

timkpaine commented Jun 30, 2020

@t-makaro jupyterlab_email does this, it has some preconfigured templates and it lets you pick and choose options. Its a little annoying to do and a little tricky to make extensible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants