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

pandoc creates ODT files which libreoffice cannot open when including 2 images #1069

Closed
wmanley opened this issue Nov 25, 2013 · 3 comments
Closed

Comments

@wmanley
Copy link

wmanley commented Nov 25, 2013

Pandoc version 1.11.1
libreoffice 4.1.3.2
on Debian testing (jessie)

libreoffice is unable to open odt files produced by pandoc if they contain more than 1 image.

Test case:

echo '<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="800" height="600" version="1.1"/>' >img1.svg
echo '![](img1.svg)
![](img1.svg)' >test.md
pandoc -o test.odt test.md
soffice test.odt

libreoffice opens and presents a dialog box reading:

Read-Error.
Error reading file

screenshot from 2013-11-25 16 07 37

The issue disappears if the image included only once.

The issue is still present when:

  • Two different images are included rather than the same one twice
  • The image is in PNG format instead of SVG.

I have not yet tested with Pandoc 1.12.1 as I am having difficulty building it.

I do not know if this is technically a libreoffice or a pandoc issue, either way I think it's important that pandoc produces ODTs that libreoffice can open as that is what the majority of people will be using to open the ODTs.

@wmanley
Copy link
Author

wmanley commented Nov 25, 2013

Issue still exists in current git HEAD 1.12.1-41-ge1a9a61 (e1a9a61)

@wmanley
Copy link
Author

wmanley commented Nov 25, 2013

The relevant part of the content.xml within the ODT file looks like (pretty-printed):

<draw:frame svg:width="0pt" svg:height="0pt">
  <draw:image xlink:href="Pictures/0.svg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" />
</draw:frame>
<draw:frame svg:width="0pt" svg:height="0pt">
  <draw:image xlink:href="Pictures/1.svg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" />
</draw:frame>

libreoffice no longer complains if you add draw:name attributes to the draw:frame elements and give them different values. It gives the same error message if the two frames have the same draw:name value as each other. e.g:

<draw:frame draw:name="graphics1" svg:width="0pt" svg:height="0pt">
  <draw:image xlink:href="Pictures/0.svg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" />
</draw:frame>
<draw:frame draw:name="graphics2" svg:width="0pt" svg:height="0pt">
  <draw:image xlink:href="Pictures/1.svg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" />
</draw:frame>

works whereas

<draw:frame draw:name="graphics1" svg:width="0pt" svg:height="0pt">
  <draw:image xlink:href="Pictures/0.svg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" />
</draw:frame>
<draw:frame draw:name="graphics1" svg:width="0pt" svg:height="0pt">
  <draw:image xlink:href="Pictures/1.svg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" />
</draw:frame>

doesn't.

wmanley added a commit to wmanley/pandoc that referenced this issue Nov 25, 2013
…open

libreoffice was unable to open odt files produced by pandoc if they
contained more than 1 image.  e.g. the markdown:

    ![](img1.svg)
    ![](img1.svg)

Passed through pandoc to create an ODT causes libreoffice (4.1.3.2) to
produce the an error in a dialog box reading:

> Read-Error.
> Error reading file

Libreoffice doesn't seem to like the values of the `draw:name` attributes
to appear more than once on different `draw:frame` XML elements.  I suspect
if the `draw:name` attribute is missing libreoffice internally defaults
to some fixed value causing a conflict if more than one image is present
in the document.

It seems like this technically a libreoffice bug, but it is important for
pandoc to produce ODT files which libreoffice can read given that it and
its cousin openoffice are likely to be the most common programs to be used
to open ODTs so this commit works around this issue in pandoc.

This commit is probably more useful as a guide as to where the code to be
fixed should be fixed rather than something that can be applied directly
to master.  It is intended as a discussion point.  I do not know Haskell
and have not written any before.  Also a test case is missing.

Fixes jgm#1069
@wmanley
Copy link
Author

wmanley commented Nov 25, 2013

Commit e7618ff fixes it for me but is probably not production ready but may be useful as an illustration of the problem.

@jgm jgm closed this as completed in 7aa4d51 Dec 1, 2013
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

1 participant