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

Failure to output embedded image to docx #18

Closed
Analect opened this issue Jul 4, 2018 · 10 comments
Closed

Failure to output embedded image to docx #18

Analect opened this issue Jul 4, 2018 · 10 comments

Comments

@Analect
Copy link

Analect commented Jul 4, 2018

@hugobuddel . Thanks for your efforts with this tool.
I was trying to get two things working. Based on the *.rst file (middle below), I am able to output html and pdf with sections numbered as well as embedded images, however neither work when outputting to a docx. Is this possible, do you know? Perhaps I'm just missing some added configuration?

Thanks.

image

@hugobuddel
Copy link
Collaborator

Thank you for the issue @Analect.

Not all features are supported in the docx plugin yet; we focused on the ones we need ourselves. I'll take a look at it next week. The image support shouldn't be difficult to add (we had it before). I don't know about the section numbering, lets see.

@Analect
Copy link
Author

Analect commented Jul 6, 2018

@hugobuddel ... much appreciated. Thanks.

@Analect
Copy link
Author

Analect commented Jul 12, 2018

@hugobuddel ... any joy in getting some of those elements working? Thanks

@hugobuddel
Copy link
Collaborator

@Analect , does attached screenshot do what you want? Created from sample_5 in the hb/feature/issue18 branch: https://github.com/mherkazandjian/docxsphinx/tree/hb/feature/issue18/examples/sample_5

Main points:

  • Image support is improved, you can now specify 'height' and 'width'. 'align' is ignored though.
  • The section numbers are defined in the styles the template docx file. 'sample_5' contains an example template. (I'm not sure exactly which style contains this information, probably one of the headers.)

docxsphinx1cut

@Analect
Copy link
Author

Analect commented Jul 18, 2018

@hugobuddel ... sorry for the delayed response. I tested your docxsphinx-hb-feature-issue18 branch and it appears to work well. Thanks for that. Is it possible for this to get merged into master?

@hugobuddel
Copy link
Collaborator

Great that it works! I've assigend #19 to @mherkazandjian to merge it into develop first.

@Analect
Copy link
Author

Analect commented Jul 18, 2018

@hugobuddel ... I'm now trying to get this working in the context of my own sphinx docs. I'm working with a conda environment where I had previously installed the master branch. I then checked out the fixed docxsphinx-hb-feature-issue18 branch ... and ran through a reinstall, as per README. Not sure if that is the right approach or not ... or if I needed to uninstall in that conda environment before reinstalling. I updated my conf.py to broadly emulate yours (in terms of referencing template.docx etc.. however, I'm hitting this error. Any thoughts on what might be causing this. I haven't necessarily added explicit widths/heights to my embedded images.

Exception occurred:
  File "C:\Users\TXXXXXX\AppData\Local\Continuum\Miniconda3\envs\client-docs\lib\site-packages\docx\shared.py", line 113, in __new__
    emu = int(points * Length._EMUS_PER_PT)
TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'

@Analect
Copy link
Author

Analect commented Jul 18, 2018

@hugobuddel ... actually ... the above was resolved by adding a width parameter to figures .. without this, I was getting the error above, for some reason.

One final question ... should this package be able to handle graphviz and perhaps plantuml

.. graphviz::

    digraph G {
    rankdir=LR
    node [shape=cds, width=1, height=1]
    "Test\n 1" -> "Test\n 2" -> "Test\n 3" -> "Test\n 4" -> "Test\n 5"
    }

resulting in ...
image

@hugobuddel
Copy link
Collaborator

thanks for testing this @Analect. The feature branch now works properly when not specifying the image dimensions.

One thing about the templates is that the plugin currently does not respect the template_path. Created #22 for this. The current situation is workable though.

We will probably not add graphviz support any time soon; would be nice though. If you wish you can create a separate issue to track it. For now you could convert the graphs to png's.

@Analect
Copy link
Author

Analect commented Jul 20, 2018

Thanks @hugobuddel ... I'll close this out for now then. Appreciate your support with this.

@Analect Analect closed this as completed Jul 20, 2018
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