-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
Describe your proposed improvement and the problem it solves
See #10741. I want to include images in my custom template.openxml
. However, images are included using rId
s, which point to Relationship
s defined in /word/_rels/document.xml.rels
. For a more detailed example of how this works, consider the Appendix below.
Because I currently have no way of controlling the contents of /word/_rels/document.xml.rels
in the output DOCX, I have no way of including images in template.openxml
. This could be fixed by including the images in the reference-doc.docx
, if pandoc preserved the reference-doc
's existing Relationship
s defined in /word/_rels/document.xml.rels
when creating the output DOCX (pandoc currently doesn't do that). I would then have rId
s for my images which I could use in template.openxml
.
I am not sure if all Relationship
s from /word/_rels/document.xml.rels
should be preserved, but at the very least those of Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
.
Pandoc already preserves the actual image files in the reference-doc
in /word/media/
when creating the output DOCX.
Describe alternatives you've considered
See #10741 for a considered alternative that doesn't actually work.
Appendix: How images are included in Word's OpenXML
When a DOCX contains an image, the corresponding OpenXML in /word/document.xml
looks something like this (Word is actually very particular about this and doesn't tolerate the removal of some elements that might seem superfluous to the minimalist OpenXML author):
<w:p>
<w:r>
<w:drawing>
<wp:inline>
<wp:extent cx="990000" cy="792000"/>
<wp:docPr id="1" name="Picture 1"/>
<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="0" name="image1.jpg"/>
<pic:cNvPicPr/>
</pic:nvPicPr>
<pic:blipFill>
<a:blip r:embed="rId8"/>
<a:stretch>
<a:fillRect/>
</a:stretch>
</pic:blipFill>
<pic:spPr>
<a:xfrm>
<a:off x="0" y="0"/>
<a:ext cx="990000" cy="792000"/>
</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>
The actual image is included in the element <a:blip r:embed="rId1"/>
, which references rId8
in this case. This rId
is defined in /word/_rels/document.xml.rels
(below is only an excerpt of that file):
<Relationship Id="rId8" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image1.png" />
The actual image file resides at /word/media/image1.png
, as defined in the Relationship
above. Without controlling the contents of /word/_rels/document.xml.rels
, one cannot therefore include an image in OpenXML.
Version
Pandoc 3.6.4