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

Docx writer problem with images in footnotes #10228

Open
Amphiboly opened this issue Sep 27, 2024 Discussed in #9602 · 7 comments
Open

Docx writer problem with images in footnotes #10228

Amphiboly opened this issue Sep 27, 2024 Discussed in #9602 · 7 comments

Comments

@Amphiboly
Copy link

Discussed in #9602

Originally posted by Amphiboly March 23, 2024
With the docx writer, images in footnotes are displayed as properly-sized box with "Picture...". The same markdown source processes as expected with the odt and ConTeXt writers.

![](burton_shoulders.png) \
Image in a footnote[^1].

[^1]: ![](burton_shoulders.png)

burton_shoulders

This was initially reported under Pandoc 3.12.3 and persists through the current (3.14) version.

@jgm
Copy link
Owner

jgm commented Sep 27, 2024

For reference, the result looks like this:
image

@jgm
Copy link
Owner

jgm commented Sep 27, 2024

I tried creating an image in a note in Word, and I noticed that it footnotes.xml.rels we got a reference to the image:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image1.jpeg"/></Relationships>

So I suspect that is the thing we're missing here.

@jgm
Copy link
Owner

jgm commented Sep 27, 2024

Current pandoc in footnotes.xml:

  <w:footnoteRef />
      </w:r>
      <w:r>
        <w:t xml:space="preserve">
        </w:t>
      </w:r>
      <w:r>
        <w:drawing>
          <wp:inline>
            <wp:extent cx="5334000" cy="891742" />
            <wp:effectExtent b="0" l="0" r="0" t="0" />
            <wp:docPr descr="" title="" id="22" name="Picture" />
            <a:graphic>
              <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
                <pic:pic>
                  <pic:nvPicPr>
                    <pic:cNvPr descr="burton_shoulders.png" id="23" name="Picture" />
                    <pic:cNvPicPr>
                      <a:picLocks noChangeArrowheads="1" noChangeAspect="1" />
                    </pic:cNvPicPr>
                  </pic:nvPicPr>
                  <pic:blipFill>
                    <a:blip r:embed="rId21" />
                    <a:stretch>
                      <a:fillRect />
                    </a:stretch>
                  </pic:blipFill>
                  <pic:spPr bwMode="auto">
                    <a:xfrm>
                      <a:off x="0" y="0" />
                      <a:ext cx="5334000" cy="891742" />
                    </a:xfrm>
                    <a:prstGeom prst="rect">
                      <a:avLst />
                    </a:prstGeom>
                    <a:noFill />
                    <a:ln w="9525">
                      <a:noFill />
                      <a:headEnd />
                      <a:tailEnd />
                    </a:ln>
                  </pic:spPr>
                </pic:pic>
              </a:graphicData>
            </a:graphic>
          </wp:inline>
        </w:drawing>
      </w:r>
    </w:p>
  </w:footnote>

From the working document.xml:

  <w:footnote w:id="1">
    <w:p w14:paraId="619C6545" w14:textId="09E8AFA1" w:rsidR="008F1B46" w:rsidRDefault="008F1B46">
      <w:pPr>
        <w:pStyle w:val="FootnoteText"/>
      </w:pPr>
      <w:r>
        <w:rPr>
          <w:rStyle w:val="FootnoteReference"/>
        </w:rPr>
        <w:footnoteRef/>
      </w:r>
      <w:r>
        <w:t xml:space="preserve"> This is a note.
        </w:t>
      </w:r>
      <w:r>
        <w:rPr>
          <w:noProof/>
        </w:rPr>
        <w:drawing>
          <wp:inline distT="0" distB="0" distL="0" distR="0" wp14:anchorId="3EA678A6" wp14:editId="472FEAD2">
            <wp:extent cx="5943600" cy="3325495"/>
            <wp:effectExtent l="0" t="0" r="0" b="1905"/>
            <wp:docPr id="90137236" name="Picture 1" descr="A couple of people playing basketball&#xA;&#xA;Description automatically generated"/>
            <wp:cNvGraphicFramePr>
              <a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1"/>
            </wp:cNvGraphicFramePr>
            <a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
              <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
                <pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
                  <pic:nvPicPr>
                    <pic:cNvPr id="90137236" name="Picture 1" descr="A couple of people playing basketball&#xA;&#xA;Description automatically generated"/>
                    <pic:cNvPicPr/>
                  </pic:nvPicPr>
                  <pic:blipFill>
                    <a:blip r:embed="rId1">
                      <a:extLst>
                        <a:ext uri="{28A0092B-C50C-407E-A947-70E740481C1C}">
                          <a14:useLocalDpi xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main" val="0"/>
                        </a:ext>
                      </a:extLst>
                    </a:blip>
                    <a:stretch>
                      <a:fillRect/>
                    </a:stretch>
                  </pic:blipFill>
                  <pic:spPr>
                    <a:xfrm>
                      <a:off x="0" y="0"/>
                      <a:ext cx="5943600" cy="3325495"/>
                    </a:xfrm>
                    <a:prstGeom prst="rect">
                      <a:avLst/>
                    </a:prstGeom>
                  </pic:spPr>
                </pic:pic>
              </a:graphicData>
            </a:graphic>
          </wp:inline>
        </w:drawing>
      </w:r>
    </w:p>
  </w:footnote>

@jgm
Copy link
Owner

jgm commented Sep 27, 2024

I've tried adding the Relationship to footnotes.xml.rels and linking to that with <a:blip r:embed="(its id)"/>, but still doesn't work.

@jgm
Copy link
Owner

jgm commented Sep 27, 2024

Ah -- I had some syntax errors. This works, with

  <?xml version="1.0" encoding="UTF-8"?><Relationships                        
  xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
  <Relationship Id="rId001"                                                   
  Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/i\
  mage" Target="media/rId21.png"/>
  </Relationships>

@jgm
Copy link
Owner

jgm commented Sep 27, 2024

So, to fix this, we need to do this:

  • For each image in a footnote, we need to add a Relationship to Relationships in footnotes.xml.rels. This should have a unique id and point to the media file as Target.

  • The <a:blip r:embed= in footnotes.xml then needs to point to the Relationship's id rather than the media item's own id.

@jgm
Copy link
Owner

jgm commented Sep 27, 2024

The current code is a bit ugly. We add References for every external link to footnotes.xml.rel, even for those not in footnotes. We can make this more targeted.

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