[IPython-User] Automatically embedding PDF version of figures

Jon Wilson jsw@fnal....
Wed Jan 23 11:46:33 CST 2013


Hi Matthias,
I had been thinking that the converter could only use the data that was 
already stored in the ipynb file in JSON, and so to have both PNG and 
PDF in my static HTML, I would need the notebook server to ask 
matplotlib to produce both versions and send them to the frontend.  Now 
I understand that nbconvert can internally convert SVG into both PNG and 
PDF (this should have been clear from your first mail, but I did not 
apprehend it).  I will look again and more closely at svg -> pdf and png.

And yes, I *will* be citing IPython, never fear!
Regards,
Jon

On 01/23/2013 11:37 AM, Matthias BUSSONNIER wrote:
> HI Jon,
>
> Do you really need to extract the files from a live notebook ?
> if I were you I would parse the ipynb file If I were you,
> it can already contain multiple repr of the same object, and nbconvert 
> can extract all of them into file :
>
> https://github.com/ipython/nbconvert/blob/master/converters/latex.py#L176
> https://github.com/ipython/nbconvert/blob/master/converters/base.py#L246
>
> And was not the
> svg -> pdf and png
> enough ?
>
> Otherwise, Yes, in recent browser it is possible to dowload a local 
> resources,
> You will have to look at 'blob' url I think, and you would probably 
> have to dive in
> Js to decode the base 64 encoded stuff.
>
> After that it behaves like normal download.
> -- 
> Matthias
>
>
> Le 23 janv. 2013 à 18:10, Jon Wilson a écrit :
>
>> Hi Matthias,
>> Thanks for the reply.  I will probably have some time to look at/work on
>> this tomorrow in the afternoon (central US time).  I was thinking about
>> trying to hook into the pylab inline backend -- have it send both the
>> png and the pdf as a payload.
>
>
>> With a data URI, is it possible to have a
>> clickable link-like tag that will cause the user agent to request to
>> save a file?  In that scenario, is it possible to give the saved file a
>> filename?
>> Regards,
>> Jon
>>
>> On 01/23/2013 02:33 AM, Matthias BUSSONNIER wrote:
>>> Hi John,
>>>
>>> Thank for your feedback, and happy for you that you will soon publish,
>>> It is nice to see people using IPython Notebook from end to end as 
>>> it is our goal.
>>>
>>> To get back to your problem, and supposing you are using matplotlib,
>>> I suggest you switch the backend to SVG.
>>>
>>>  %config InlineBackend.figure_format = 'svg'
>>> for only the current session, or
>>> c.InlineBackend.figure_format = 'svg'
>>> in your profile.
>>>
>>> Nbconvert will be smart enough to extract the svg and make pdf from 
>>> them if you issue a
>>> $ nbconvert --format latex yourfile.ipynb
>>>
>>> As usually the sag render well in browser, It will  not make png 
>>> from svg for the html format,
>>> but that shouldn't be too hard to add.
>>>
>>> Concerning the clickable png that lead to the PDF, it shouldn't need 
>>> too much change
>>> on nbconvert either, and will likely not be much more complicated 
>>> than adding the link by hand in the HTML.
>>>
>>> As we are currently rebuilding nbconvert from the ground up, those 
>>> feature will probably not
>>> be integrated in the current version, but depending how much time 
>>> you have, we could
>>> probably hack things quickly to do something for you.
>>>
>>> If this seem ok to you, I'll let you open a issue on nbconvert issue 
>>> tracker, and then we'll see what we can do.
>>>
>>
>> _______________________________________________
>> IPython-User mailing list
>> IPython-User@scipy.org <mailto:IPython-User@scipy.org>
>> http://mail.scipy.org/mailman/listinfo/ipython-user
>
>
>
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20130123/c5b0f6d2/attachment-0001.html 


More information about the IPython-User mailing list