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
PDF figures as links from png or svg figures #4130
Conversation
of figure_format. This can probably be done better, since the way I've done it, it is not configurable at all.
… href and with the download attribute set, when application/pdf data is available from JSON
Thanks for re-issuing, now we can start reviewing in earnest. A few points:
I think it's appropriate for this initial PR to do a little bit less:
We can save the js UI for PDFs for later work. |
I agree with @minrk the pdf option is nice, however it should be configurable and disabled by default. Otherwise, the |
"however" sounds like you disagree, but my very first point was that PDF should not be on by default, so I think we are on the same page. |
Sorry for my ambiguous english 😳 |
Yes, I agree that it should not be on by default. I think that If the latter, is there already an extant config mechanism in place for turning on a set of options? I'm imagining something like
I'm also happy to remove the JS stuff for now -- I think my changes are somewhat kludgy as is (doesn't work for SVG+PDF, for example), so will need more careful work before they are ready to be incorporated. I'll continue using what I have now, though. It works perfectly for me and my use-case. :-) |
@jsw-fnal note that we want to have a general way of sending any mimetype to the browser. We are moving away from special-casing everything, so we will be happy to get you to contribute. Personnaly I would change Any step toward this would be great I think. As for the javascript thing It might be too specific also. A way of dynamically switching representation might be great to. |
What do we want to do with this PR? If we plan on work continuing, can we create a todo list for what needs to be done? |
@ellisonbg, I don't know that I have time right now to refactor the system of sending mimetypes to the browser, as @Carreau says. That would require considerably more comprehension of the existing code than I have right now. If you're willing to wait perhaps several months, I'm happy to spend the time, as I have it, to try to figure this out. Regarding the JS, I'm no UX expert, so perhaps it is best to let someone else tackle that. I'll take a stab at a todo list:
I think that, if 1 and 2 are done, perhaps you could merge this, and leave 3 and 4 for future work? |
I would actually skip 2. as well - there is a high cost to changing configurable names, and I don't think adding an s is sufficiently beneficial to warrant breakage. I also think the general addition of mime types is out of scope for this PR, and to be done by someone with more intimate knowledge of the affected pieces. I think the list I made above should be sufficient:
|
Unfortunately, no. I'm in the middle of a push to get a result out and I'm changing jobs at the end of the year, so it may be a little while before I get back to this. Should we just close the PR for now? I can re-open it I guess when I can get back to this. On the plus side, we got this paper accepted to Phys Rev Lett last week. It cites you guys :) |
So... what do we do with this one? |
We talked about this today at the dev meeting and decided the following:
|
Also needs a rebase. |
@jsw-fnal do you have plans on getting to this soon. It would be great to have this in for the 2.0 release which is going to be in the next few weeks. If you don't think you will find time to work on it, just let us know and we can probably take over. |
Sadly, I think I will not be able to do this on that timescale. On 01/27/2014 04:19 PM, Brian E. Granger wrote:
|
OK I will take over for you - thanks for bringing it this far! On Mon, Jan 27, 2014 at 2:21 PM, jsw-fnal notifications@github.com wrote:
Brian E. Granger |
Ongoing work is here #4921 |
I've implemented a feature that I've wanted for a while. When a figure is displayed, the img is a link to a PDF version of the figure. This follows the convention for webpages in my collaboration, where a figure should be displayed on the webpage as a raster, but a vector (eps or pdf) needs to be available for people to use in LaTeX.
To do this, I made four changes. First, I added a PDFFormatter class to formatters.py, and registered it as a formatter. Then, I changed pylabtools.py to always generate PDF output, whether
figure_format
is "png", "svg", or "retina". I think this part still needs some work, as it is currently not configurable. Then, I made jsonutil.py detect and encode PDF data in base64. Finally, I added the necessary javascript to outputarea.js to wrap the anchor tag around the img tag.I have not tested how this interacts with nbconvert, because my system does not have Haskell available. I have to convince the sysadmins that I really need it before I can try to set up pandoc. So I may need some assistance in that regard.
I hope that this new feature is helpful and can eventually make it into ipython.
Best regards,
Jon