drmacro / wordinator

Generate high-quality DOCX files using a simplified XML format (simple word processing XML).
Apache License 2.0
37 stars 8 forks source link

A particular SWPX generates a DOCX file whose content does not include all of the input #154

Open gkholman opened 1 month ago

gkholman commented 1 month ago

The DOCX file ends abruptly at the bottom of page 11. Following content is not visible/accessible.

Interestingly, it seems the document cannot be printed using the Microsoft PDF print driver.

Test file sent under separate cover.

drmacro commented 1 month ago

The direct cause of the failures is empty callout attributes on the elements:

<wp:fn callout="" id="fn_1">

For reasons that are not clear, after a certain number of footnotes, those footnotes cause the rest of the document to not render in Word.

If I either set a value in the callout attributes or remove them entirely, then the document works as it should.

drmacro commented 1 month ago

However, the resulting document's footnotes end up with duplicate callouts.

I notice that the footnotes as generated in the supplied SWPX file use run-level styling to style the callouts rather than setting the callout style on the footnote itself.

I think the answer is to generate the footnotes such that callout= has a value and the callout styling is done via styles, but I need to research how to do that.

drmacro commented 1 month ago

The issue with the callout size is that the style named FootnoteReference is not defined in the template, so callouts created with the callout= attribute are rendered in the default character style.

If I add a style definition for FootnoteReference to the document's style section then the callouts are rendered as desired. This is the raw DOCX markup I used:

  <w:style w:type="character" w:styleId="FootnoteReference">
    <w:name w:val="Footnote Reference"/>
    <w:basedOn w:val="DefaultParagraphFont"/>
    <w:rsid w:val="00EC5EAEFF"/>
    <w:rPr>
      <w:vertAlign w:val="superscript"/>
      <w:sz w:val="10"/>
    </w:rPr>

  </w:style>

So I think the action is:

  1. Add the FootnoteReference character style to the template
  2. Use the callout= attribute to specify the footnote callout rather than using the current literal runs. (I also observe that the callout text in the generated footnotes are also hyperlinks, which is probably not intended or desired).
  3. Remove the literal callout runs from the output.