karnov / htmltoword

Ruby html to word gem
MIT License
179 stars 71 forks source link

List item bullets corrupted in Microsoft Word #73

Open dv opened 6 years ago

dv commented 6 years ago

It seems list item bullets render as corrupt characters in Microsoft Word. No issue in other software we tried (Pages, Preview, ...).

require "htmltoword"

html = "<ul><li>Line 1</li><li>Line 2</li></ul>"
file = Htmltoword::Document.create_and_save(html, "test.docx")

Result:

After an initial comparison of the xml files of the corrupted list versus of a working list, it seems removing these lines:

      <w:rPr>
        <w:rFonts w:ascii="Symbol" w:hAnsi="Symbol" w:hint="default"/>
      </w:rPr>

from the numbering.xml file solves this problem (but might cause others, I'm not sure what these lines do), which might give a hint towards how to solve this.

dv commented 6 years ago

I have removed

      <xsl:if test="contains($style, 'bullet')">
        <w:rPr>
          <w:rFonts w:ascii="Symbol" w:hAnsi="Symbol" w:hint="default"/>
        </w:rPr>
      </xsl:if>

From the numbering.xslt file and that seems to work for us as a workaround.