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

How to allow export to PDF? #25

Open
Naereen opened this issue Feb 14, 2021 · 2 comments
Open

How to allow export to PDF? #25

Naereen opened this issue Feb 14, 2021 · 2 comments

Comments

@Naereen
Copy link
Contributor

Naereen commented Feb 14, 2021

Hello there,

Description

First of all, I LOVE your extension, I really like it and plan to use it intensely for my teaching material from now on.
The support for HTML export (including in a Jupyter book, for instance here) is excellent.
Capture d’écran_2021-02-14_18-02-49

What I Did

But I would also like to be able to export the Tikz figures to PDF, but apparently it breaks the jupyter-nbconvert --to pdf command:

$ jupyter-nbconvert --to pdf ExamplePython.ipynb
[NbConvertApp] Converting notebook Exemple de notebook avec OCaml.ipynb to pdf
Warning: Option --without-gui= is deprecated
Warning: Option --export-pdf= is deprecated

** (org.inkscape.Inkscape:6978): WARNING **: 17:31:49.318: Can't open file: /tmp/tmphabmy2re/figure.svg (doesn't exist)

** (org.inkscape.Inkscape:6978): WARNING **: 17:31:49.318: Can't open file: /tmp/tmphabmy2re/figure.svg (doesn't exist)
ink_file_open: '/tmp/tmphabmy2re/figure.svg' cannot be opened!
InkscapeApplication::document_open: Failed to open: /tmp/tmphabmy2re/figure.svg
ConcreteInkscapeApplication::on_open: failed to create document!
Traceback (most recent call last):
  File "/usr/local/bin/jupyter-nbconvert", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/dist-packages/jupyter_core/application.py", line 270, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/jupyter_core/application.py", line 270, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/traitlets/config/application.py", line 664, in launch_instance
    app.start()
  File "/usr/local/lib/python3.6/dist-packages/nbconvert/nbconvertapp.py", line 340, in start
    self.convert_notebooks()
  File "/usr/local/lib/python3.6/dist-packages/nbconvert/nbconvertapp.py", line 510, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "/usr/local/lib/python3.6/dist-packages/nbconvert/nbconvertapp.py", line 481, in convert_single_notebook
    output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer)
  File "/usr/local/lib/python3.6/dist-packages/nbconvert/nbconvertapp.py", line 410, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "/usr/local/lib/python3.6/dist-packages/nbconvert/exporters/exporter.py", line 179, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "/usr/local/lib/python3.6/dist-packages/nbconvert/exporters/exporter.py", line 197, in from_file
    return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
  File "/usr/local/lib/python3.6/dist-packages/nbconvert/exporters/pdf.py", line 171, in from_notebook_node
    nb, resources=resources, **kw
  File "/usr/local/lib/python3.6/dist-packages/nbconvert/exporters/latex.py", line 88, in from_notebook_node
    return super(LatexExporter, self).from_notebook_node(nb, resources, **kw)
  File "/usr/local/lib/python3.6/dist-packages/nbconvert/exporters/templateexporter.py", line 307, in from_notebook_node
    nb_copy, resources = super(TemplateExporter, self).from_notebook_node(nb, resources, **kw)
  File "/usr/local/lib/python3.6/dist-packages/nbconvert/exporters/exporter.py", line 139, in from_notebook_node
    nb_copy, resources = self._preprocess(nb_copy, resources)
  File "/usr/local/lib/python3.6/dist-packages/nbconvert/exporters/exporter.py", line 316, in _preprocess
    nbc, resc = preprocessor(nbc, resc)
  File "/usr/local/lib/python3.6/dist-packages/nbconvert/preprocessors/base.py", line 47, in __call__
    return self.preprocess(nb, resources)
  File "/usr/local/lib/python3.6/dist-packages/nbconvert/preprocessors/base.py", line 69, in preprocess
    nb.cells[index], resources = self.preprocess_cell(cell, resources, index)
  File "/usr/local/lib/python3.6/dist-packages/nbconvert/preprocessors/convertfigures.py", line 46, in preprocess_cell
    self.from_format, output.data[self.from_format])
  File "/usr/local/lib/python3.6/dist-packages/nbconvert/preprocessors/svg2pdf.py", line 110, in convert_figure
    raise TypeError("Inkscape svg to pdf conversion failed")
TypeError: Inkscape svg to pdf conversion failed

  • itikz version: 0.1.5
  • Python version: 3.6.9
  • Operating System: Ubuntu (GNU/Linux) 18.04

Thanks in advance! Regards, -- @Naereen

@jbn
Copy link
Owner

jbn commented Mar 12, 2021

Hello, @Naereen.

Thanks for the kind words, and I'm glad you find it useful!

I used this for my entire dissertation and it worked fine. So I know it does work...but I guess maybe I forgot to document something important. I'm going to grab it from my archives and figure it out this weekend. If I don't, please feel free to ping me. (Sorry for the dreadful delay).

@Naereen
Copy link
Contributor Author

Naereen commented Mar 12, 2021

Hi @jbn,
Don't you worry about the delay, 26 days is nothing in the open source software world!
Congrats for your PhD defense I guess, bravo!

I'll come back at you in a few weeks if this has not seen any reply. But no pressure please :angel !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants