Closed aroberge closed 6 years ago
@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.
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 https://github.com/jupyter/notebook/issues/840#issuecomment-164142268.
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
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.
This is a bootstrap thing that include a print.less
with !important
.
It's not easy to get rid of, but we can try.
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 !
https://github.com/mjbright/jupyter_notebooks/tree/master/2016-Feb_Docker_Build_Lab
@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 https://github.com/jupyter/nbconvert/issues/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.
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 https://github.com/jupyter/notebook/issues/840#issuecomment-179667017.
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 https://github.com/jupyter/notebook/issues/840#issuecomment-164175466.
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.
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 https://github.com/jupyter/notebook/issues/840#issuecomment-179952484.
That's wonderful! :sunrise:
Thanks @Carreau :+1:
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.
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.
(reopened)
My apologies for not reading to the top of the message list @aroberge. Thanks @Carreau for reopening.
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.
@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.
Yeah, I'm pretty sure any BW print settings are not intended. A LESS PR fixing this would be welcome.
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.
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.
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.
@marrabld Is it possible to do this with javascript, then it could be embedded in the saved html document.
@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]
+1 from me
@minrk @Carreau are we any closer to being able to fix this in our LESS files?
@minrk @Carreau are we any closer to being able to fix this in our LESS files?
AFAICT, no, not without updating to new bootstrap.
Bumped from 5.0 to backlog so we can try to get to a release.
Any idea how this is coming? I wasted a few hours toiling on this ... hoping others won't need to
same story here... trying to fix it with workarounds but I'm wasting too much time on it - without success :(
jupyter nbconvert --to slides NOTEBOOK_NAME.ipynb
It prints in color and structure is as in the notebook itself (code chunks highlighted, etc.)
It should be --to html
in the above comment
Still working at this myself...
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 :smile: 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.
I would love this to be fixed too. Doesn't seem like it would be difficult to change either.
+1
I've had a go at it in #3212 , though it's a rather ugly solution.
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~
Or upgrade to notebook 5.4 - we've removed the line for you.
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?
We need to do a new release of nbconvert to pick it up - see https://github.com/jupyter/nbconvert/pull/748
Thank you Matthias Bussonnier. The (Ctrl-Shift-R) worked for me and I can print Jupyter documents in color format. https://github.com/jupyter/notebook/issues/840#issuecomment-179952484
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.