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

Color printing should be an option (or should be the default?) #840

Closed
aroberge opened this issue Dec 11, 2015 · 41 comments · Fixed by #3212

Comments

@aroberge
Copy link

commented Dec 11, 2015

Buried in the css files are various @media print configurations which prevent color printing. They can be edited by hand if one has access to the installation directories, but there should be a way to have color printing be done without this type of editing.

@willingc

This comment has been minimized.

Copy link
Member

commented Dec 12, 2015

@aroberge Thanks for the suggestion. Personally, I never noticed that printing defaults to B&W whether from the Print Preview menu option or the browser print menu (at least on Firefox).

@Carreau @ellisonbg Is there a setting that can be easily changed to enable color printing? If so, it would seem reasonable to document here and the user docs.

@ellisonbg

This comment has been minimized.

Copy link
Contributor

commented Dec 12, 2015

Hmm, I don't think we set anything that makes it BW. We will have to look
into this.

On Sat, Dec 12, 2015 at 3:54 AM, Carol Willing notifications@github.com
wrote:

@aroberge https://github.com/aroberge Thanks for the suggestion.
Personally, I never noticed that printing defaults to B&W whether from the
Print Preview menu option or the browser print menu (at least on Firefox).

@Carreau https://github.com/carreau @ellisonbg
https://github.com/ellisonbg Is there a setting that can be easily
changed to enable color printing? If so, it would seem reasonable to
document here and the user docs.


Reply to this email directly or view it on GitHub
#840 (comment).

Brian E. Granger
Associate Professor of Physics and Data Science
Cal Poly State University, San Luis Obispo
@ellisonbg on Twitter and GitHub
bgranger@calpoly.edu and ellisonbg@gmail.com

@aroberge

This comment has been minimized.

Copy link
Author

commented Dec 12, 2015

I've installed Jupyter + IPython using the Anaconda Python distribution. In my system, the relevant css file is (if I am not mistaken):
Anaconda3/pkgs/notebook-4.06-py34_0/Lib/site-packages/notebook/static/style/style.min.css

Edit: from memory, there were two places where I removed code from the css file to print everything in color. The first place was near the @media print declaration; the second was a setting for html tables if I recall correctly.

@Carreau

This comment has been minimized.

Copy link
Contributor

commented Dec 12, 2015

This is a bootstrap thing that include a print.less with !important.
It's not easy to get rid of, but we can try.

@Carreau Carreau added this to the wishlist milestone Dec 14, 2015

@mjbright

This comment has been minimized.

Copy link

commented Feb 4, 2016

Any progress on this?
Let me bump this one - it's really important to me.

I'm using Jupyter (+bash_kernel) to create some labs (Docker) where I use Jupyter to create the lab and then create a PDF to distribute to the students-*.

Those documents would be much more readable in colour.

Thanks for a great tool !

@Carreau

This comment has been minimized.

Copy link
Contributor

commented Feb 4, 2016

@mjbright have you tried the conversion to PDF via latex ? (it likely fail because of some ansi escape sequence but that's a bug that should be opened)(opened as jupyter/nbconvert#228)

Are you afraid of a custom IPython build ? Basically set-up a dev environment,
modify <repo root>/notebook/static/components/bootstrap/less, to remove line 13 @import "print.less";, and recompile CSS (python setup.py css)

That should be enough (understand it works for me locally), unfortunately that something that make the build process extremely inconvenient for downstream (like Debian) as then we use a modified version of our dependencies.

@mjbright

This comment has been minimized.

Copy link

commented Feb 4, 2016

Hi Matthias,

I did try briefly PDF via latex (quite a week I don't even remember if it
was under RHEL7, Ubuntu-trusty or Win8 that I tried) but without early
installation success I abandoned - because of soe lab setup constraints.
I'll try again with my Ubuntu (a Vagrant box) ... when I have time (?).

Afraid of a custom IPython build? A little (time wise) but i'll consider
that also.
Mind you why are we talking about IPython?

Thanks for the suggestions,
Mike.

On 4 February 2016 at 07:21, Matthias Bussonnier notifications@github.com
wrote:

@mjbright https://github.com/mjbright have you tried the conversion to
PDF via latex ? (it likely fail because of some ansi escape sequence but
that's a bug that should be opened)

Are you afraid of a custom IPython build ? Basically set-up a dev
environment,
modify /notebook/static/components/bootstrap/less, to remove
line 13 @import "print.less";, and recompile CSS (python setup.py css)

That should be enough (understand it works for me locally),
unfortunately that something that make the build process extremely
inconvenient for downstream (like Debian) as then we use a modified
version of our dependencies.


Reply to this email directly or view it on GitHub
#840 (comment).

@mjbright

This comment has been minimized.

Copy link

commented Feb 4, 2016

Hi, following a suggestion somewhere on StackOverflow, I think, I modified
that equivalent path on my Ubuntu system.

The following context diff shows what I tried (out of informed ignorance).
Restarting Jupyter didn't improve the situation.

Just in case someone has a quick hack to suggest ...

---

/home/vagrant/anaconda3/pkgs/notebook-4.1.0-py35_0/lib/python3.5/site-packages/notebook/static/style/style.min.
css     2016-02-04 05:37:14.921859360 +0000

---

/home/vagrant/anaconda3/pkgs/notebook-4.1.0-py35_0/lib/python3.5/site-packages/notebook/static/style/style.min.
css.orig        2016-02-04 05:35:56.893856260 +0000

---

**\* 192,198 ****

*:before,

*:after {

background: transparent !important;


!     /\* To allow colour printing: color: #000 !important;*/

box-shadow: none !important;

text-shadow: none !important;

}


--- 192,198 ----

*:before,

*:after {

background: transparent !important;


!     color: #000 !important;

box-shadow: none !important;

text-shadow: none !important;

}


---

**\* 242,252 ****

.dropup > .btn > .caret {

border-top-color: #000 !important;

}

-   /\* To allow colour printing:
  
  .label {
  
    border: 1px solid #000;
  
  }
-   */
  
  .table {
  
    border-collapse: collapse !important;
  
  }

--- 242,250 ----

On 12 December 2015 at 19:45, André Roberge notifications@github.com
wrote:

I've installed Jupyter + IPython using the Anaconda Python distribution.
In my system, the relevant css file is (if I am not mistaken):

Anaconda3/pkgs/notebook-4.06-py34_0/Lib/site-packages/notebook/static/style/style.min.css


Reply to this email directly or view it on GitHub
#840 (comment).

@Carreau

This comment has been minimized.

Copy link
Contributor

commented Feb 4, 2016

Mind you why are we talking about IPython?

gah, old habits and it was late at night, I was of course trying to say Jupyter Notebook

Hi, following a suggestion somewhere on StackOverflow, I think, I modified
that equivalent path on my Ubuntu system.

Force reload the page (Ctrl-Shift-R, likely) the browsers can have agressive caching.

@mjbright

This comment has been minimized.

Copy link

commented Feb 4, 2016

La honte (duh!) for Ctrl-Shift-R !
Thanks Matthieu, I have colour printing now !!

On 4 February 2016 at 18:15, Matthias Bussonnier notifications@github.com
wrote:

Mind you why are we talking about IPython?

gah, old habits and it was late at night, I was of course trying to say Jupyter
Notebook

Hi, following a suggestion somewhere on StackOverflow, I think, I modified
that equivalent path on my Ubuntu system.

Force reload the page (Ctrl-Shift-R, likely) the browsers can have
agressive cahing.


Reply to this email directly or view it on GitHub
#840 (comment).

@willingc

This comment has been minimized.

Copy link
Member

commented Feb 4, 2016

That's wonderful! 🌅

Thanks @Carreau 👍

@willingc willingc closed this Feb 4, 2016

@aroberge

This comment has been minimized.

Copy link
Author

commented Feb 4, 2016

I am curious as to why has this just been closed? It still requires custom editing of one file in the distribution if I am not mistaken. If I understand correctly, the Ctrl-Shift-R was just done so that the browser would use the file edited by hand but the underlying problem is still there.

@Carreau Carreau reopened this Feb 4, 2016

@Carreau

This comment has been minimized.

Copy link
Contributor

commented Feb 4, 2016

I am curious as to why has this just been closed?

This was likely a mistake, it happen when you get notification by mail, and only see the last few messages.

@Carreau

This comment has been minimized.

Copy link
Contributor

commented Feb 4, 2016

(reopened)

@willingc

This comment has been minimized.

Copy link
Member

commented Feb 4, 2016

My apologies for not reading to the top of the message list @aroberge. Thanks @Carreau for reopening.

@AGS-Knight

This comment has been minimized.

Copy link

commented Feb 9, 2016

Could someone explain this to me - I, too, am interested in printing in color. I am able to generate .html files of my notebook that look correct, but when I print them or save as .pdf when printing, only the inline figures show color. This is the case whether or not I comment the lines that @Carreau suggested, above.

@takluyver

This comment has been minimized.

Copy link
Member

commented Feb 9, 2016

@AGS-Knight if you're modifying the LESS files, you'll need to recompile them to CSS, reinstall the notebook, and convince your browser to clear the cache before you'll see any effect.

It should absolutely be possible to print in colour without going through this.

@minrk minrk modified the milestones: 5.0, wishlist Feb 9, 2016

@minrk

This comment has been minimized.

Copy link
Member

commented Feb 9, 2016

Yeah, I'm pretty sure any BW print settings are not intended. A LESS PR fixing this would be welcome.

@Carreau

This comment has been minimized.

Copy link
Contributor

commented Feb 9, 2016

A LESS PR fixing this would be welcome.

It was like that before, but it requires a modified version of bootstrap. We were removing code.less and print.less, though it required too much maintenance at each update, and completely screw up packaging by thongs like debian.

@lia-simeone

This comment has been minimized.

Copy link

commented May 6, 2016

Is the intent still to fix this issue? Any estimate on when it might be fixed?

Printing notebooks to PDF is one of my favorite features, but black and white really reduces the usefulness.

@marrabld

This comment has been minimized.

Copy link

commented Aug 2, 2016

One workaround is, save the notebook as html. The rendered file will have the css embedded. Open the HTML in a text editor and do a search for

@media print

and delete the offending

!important;color:#000

save, open the file in a browser and print.

It's not ideal but you don't have to go digging around changing the CSS and recompiling in your site-packages.

Just in case someone is looking for an easier workaround.

@vascotenner

This comment has been minimized.

Copy link

commented Aug 2, 2016

@marrabld Is it possible to do this with javascript, then it could be embedded in the saved html document.

@marrabld

This comment has been minimized.

Copy link

commented Aug 3, 2016

@vascotenner I guess so, but my Javascript isn't good enough to figure out how to do it.

[edit]
You could try adding
@media print { *, *:before, *:after { background: transparent !important; box-shadow: none !important; text-shadow: none !important; }

to your ~/.jupyter/custom/custom.css file.
[\edit]

@Eothred

This comment has been minimized.

Copy link

commented Sep 27, 2016

+1 from me

@takluyver

This comment has been minimized.

Copy link
Member

commented Jan 31, 2017

@minrk @Carreau are we any closer to being able to fix this in our LESS files?

@Carreau

This comment has been minimized.

Copy link
Contributor

commented Jan 31, 2017

@minrk @Carreau are we any closer to being able to fix this in our LESS files?

AFAICT, no, not without updating to new bootstrap.

@takluyver takluyver modified the milestones: Backlog, 5.0 Jan 31, 2017

@takluyver

This comment has been minimized.

Copy link
Member

commented Jan 31, 2017

Bumped from 5.0 to backlog so we can try to get to a release.

@lucasdurand

This comment has been minimized.

Copy link

commented Jun 14, 2017

Any idea how this is coming? I wasted a few hours toiling on this ... hoping others won't need to

@raoulraf

This comment has been minimized.

Copy link

commented Aug 17, 2017

same story here... trying to fix it with workarounds but I'm wasting too much time on it - without success :(

@itacdonev

This comment has been minimized.

Copy link

commented Aug 21, 2017

  1. Saving as slides using
    jupyter nbconvert --to slides NOTEBOOK_NAME.ipynb
  2. opening in Text Editor (Mac)
  3. open print dialog and uncheck the option to "rewrap contents to fit the page". If you leave this option the font size is large.
  4. adjust any other printing options
  5. print

It prints in color and structure is as in the notebook itself (code chunks highlighted, etc.)

@itacdonev

This comment has been minimized.

Copy link

commented Aug 21, 2017

It should be --to html in the above comment

@MathRanger6

This comment has been minimized.

Copy link

commented Sep 25, 2017

Still working at this myself...

@LukeLR

This comment has been minimized.

Copy link

commented Nov 6, 2017

Any progress so far? I'm using Jupyter Notebook on a regular basis, and my work requires me to print my notebooks. Printing without color looks ugly, since the code is harder to read and less understandable. Printing via LaTeX/PDF works in color, but lines longer than the page width are cut off. So both options don't work for me.

Jupyter Notebook is a great tool and I love everything about it - except the printing / PDF export 😄 Besides that, it works very flawlessly and I love the openness of the code and the file format, and the reliability of the software. Great work! But, please, add an option for colored printing.

For those who don't want to modify their sources because of installing via package manager or temporary fixes, but still want colored printing: Using Firefox dev console (Ctrl+Shift+C) when viewing the print preview (File > Print preview) or a rendered HTML of the desired file, switch to the "Style editor" tab and select the largest style sheet (for me it's Inline Style Sheet #1 with 2199 rules). Search for "print" by Ctrl+F and comment out the line color: #000 !important; (line 196 for me) by wrapping in /* */, like that:

/*color: #000 !important;*/

Then print with Ctrl+P, maybe reload the page if it isn't updated automatically. If it doesn't work, you might try commenting out the whole print { ... } section.

@NicholasFarrow

This comment has been minimized.

Copy link

commented Dec 20, 2017

I would love this to be fixed too. Doesn't seem like it would be difficult to change either.

@phablulo

This comment has been minimized.

Copy link

commented Jan 13, 2018

+1

@takluyver

This comment has been minimized.

Copy link
Member

commented Jan 15, 2018

I've had a go at it in #3212 , though it's a rather ugly solution.

@PeterXiaoGuo

This comment has been minimized.

Copy link

commented Feb 13, 2018

Hi, for anyone who get lost in the long communication log and want to find the solution for colored pdf output quickly:

Just comment one line code below in a css file called "style.min" in C:\Users***\Anaconda3\Lib\site-packages\notebook\static\style

comment the 195th line:
color: #000 !important;

it's in a stuff called @media print {.....}
control + Q for notepad

Good luck~

@takluyver

This comment has been minimized.

Copy link
Member

commented Feb 13, 2018

Or upgrade to notebook 5.4 - we've removed the line for you.

@MathRanger6

This comment has been minimized.

Copy link

commented Jun 7, 2018

I'm still having this problem with both 5.4 and 5.5. I go to file - print preview, and then print. It uses the same bootstrap and the same line of code is in there telling it color 0000. What am I doing wrong?
boot

@takluyver

This comment has been minimized.

Copy link
Member

commented Jun 7, 2018

We need to do a new release of nbconvert to pick it up - see jupyter/nbconvert#748

@farhadsalemi1

This comment has been minimized.

Copy link

commented Nov 3, 2018

Thank you Matthias Bussonnier.
The (Ctrl-Shift-R) worked for me and I can print Jupyter documents in color format.
#840 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.