How to customize the pdf/zip filename in exporting a notebook

226 views
Skip to first unread message

Xuefeng LIU

unread,
Oct 20, 2015, 1:56:27 AM10/20/15
to Project Jupyter
Dear Sir or madam,

Since the name of notebook can have none ASCII characters, I would like to set the name of exported file to be a fixed one, for example, "export.pdf".

Could anyone give me any hint on how to customize the file name, or where to modify the source code?

Thanks a lot!

Xuefeng LIU


Matthias Bussonnier

unread,
Oct 20, 2015, 2:02:54 PM10/20/15
to jup...@googlegroups.com
Hi Xuefeng,

the following give you some of the options available:

$ jupyter nbconvert --help
...
--output=<Unicode> (NbConvertApp.output_base)
Default: ''
overwrite base name use for output files. can only be used when converting
one notebook at a time.


Which mean that you should be able to either pass the `--output export.pdf` flag, or set it globally in you config as `c.NbConvertApp.output_base=‘export.pdf’`.

Thanks,
--
M

Xuefeng LIU

unread,
Oct 20, 2015, 8:27:57 PM10/20/15
to Project Jupyter
Hi, Matthias,

Thanks for your response.

It seems that the global option does not work well. Could you give me any further advice?

Below is the config file.



# Configuration file for ipython.
c
= get_config()
c
.IPKernelApp.pylab = 'inline'
c
.IPKernelApp.matplotlib = 'inline'
c
.NotebookApp.ip = '*'
c
.NotebookApp.open_browser = False
c
.NotebookApp.port = 8080
c
.PDFExporter.latex_command = ['xelatex', '{filename}']
c
.NbConvertApp.output_base='export'



The command to run the notebook is as below:


jupyter
-notebook --config=/etc/ces/ipython/profile_myserver/ipython_config.py --notebook-dir=/home/XXXX


The environment of the python: 


ipykernel                 4.1.0                    py27_0  
ipython                  
4.0.0                    py27_0  
ipython
-genutils          0.1.0                     <pip>
ipython
-notebook          4.0.4                    py27_0  
ipython_genutils          
0.1.0                    py27_0  
ipywidgets                
4.0.3                    py27_0  
isl                      
0.12.2                        0  
jinja2                    
2.8                      py27_0  
jsonschema                
2.4.0                    py27_0  
jupyter                  
1.0.0                    py27_0  
jupyter
-client            4.1.1                     <pip>
jupyter
-console           4.0.3                     <pip>
jupyter
-core              4.0.6                     <pip>
jupyter_client            
4.1.1                    py27_0  
jupyter_console          
4.0.3                    py27_0  
jupyter_core              
4.0.6                    py27_0  
nbconvert                
4.0.0                    py27_0  
nbformat                  
4.0.1                    py27_0  
notebook                  
4.0.6                    py27_0  
numexpr                  
2.4.4               np19py27_p0  [mkl]
numpy                    
1.9.3                   py27_p0  [mkl]



2015年10月21日水曜日 3時02分54秒 UTC+9 Matthias Bussonnier:

Matthias Bussonnier

unread,
Oct 20, 2015, 9:10:22 PM10/20/15
to jup...@googlegroups.com, Xuefeng LIU
Hi there, 

I just did the following : 


$ jupyter nbconvert --generate-config
$ vim ~/.jupyter/jupyter_nbconvert_config.py
# edit the config accordingly.
$ cat ~/.jupyter/jupyter_nbconvert_config.py  | grep -e '^c'
c.NbConvertApp.output_base = 'exported-base-from-config

$ jupyter nbconvert --to latex 'Advance python.ipynb'
[NbConvertApp] Converting notebook Advance python.ipynb to latex
[NbConvertApp] Writing 57050 bytes to exported-base-from-config.tex

$ ls -1 *.tex
exported-base-from-config.tex


(it fails with --to pdf, but I expect that to be a bug, filled as https://github.com/jupyter/nbconvert/issues/144

I’m not sure why it does not work for you. Did you modified the right config file ?

-- 
M





--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/cbe8f1b9-f1b7-4aea-bcb9-4ef7b6004c7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Xuefeng LIU

unread,
Oct 21, 2015, 9:20:50 PM10/21/15
to Project Jupyter, xfliu...@gmail.com

I run the "jupyter nbconvert --to pdf" directly, then it woks well.

jupyter nbconvert --to pdf 2D_FEM.ipynb --config=/etc/ces/ipython/profile_myserver/ipython_config.py

But if I download the PDF file from the File menu by using a browser, then the created file name is not following the specified option. (See attached screenshot.)

So, it seems to be a bug of jupyter notebook, that is, the NbConvert option in config file CANNOT is loaded to nbconvert when downloading a notebook as PDF.





2015年10月21日水曜日 10時10分22秒 UTC+9 Matthias Bussonnier:
Reply all
Reply to author
Forward
0 new messages