6
您知道基本信息必须在document.xml中的段落(<w:p/>
)中包含指定图像的* .docx文档吗?我知道必须有:Word 2007,Open XML - 嵌入图像
<a:blip r:embed="rId4" />
指定关系id,但还有什么? 在Google中很难找到它,并尝试从现成文档中删除标签或阅读规范需要花费大量时间。
所有所需标签的例子将不胜感激。
您知道基本信息必须在document.xml中的段落(<w:p/>
)中包含指定图像的* .docx文档吗?我知道必须有:Word 2007,Open XML - 嵌入图像
<a:blip r:embed="rId4" />
指定关系id,但还有什么? 在Google中很难找到它,并尝试从现成文档中删除标签或阅读规范需要花费大量时间。
所有所需标签的例子将不胜感激。
对于提供的输入XML而言,单词是比较挑剔的。要嵌入图像,您必须提供相当多的信息。下面是一个简单的例子:
document.xml中
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:body>
<w:p>
<w:r>
<w:drawing>
<wp:inline distT="0" distB="0" distL="0" distR="0">
<wp:extent cx="5943600" cy="3717290"/>
<wp:docPr id="1" name="Picture 0" descr="vlcsnap-325726.png"/>
<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="myImage.png"/>
<pic:cNvPicPr/>
</pic:nvPicPr>
<pic:blipFill>
<a:blip r:embed="rId4"/>
<a:stretch>
<a:fillRect/>
</a:stretch>
</pic:blipFill>
<pic:spPr>
<a:xfrm>
<a:off x="0" y="0"/>
<a:ext cx="5943600" cy="3717290"/>
</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:body>
</w:document>
document.xml.rels
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<!-- other relationships go here -->
<Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image1.png"/>
</Relationships>
当然的图像必须在正确的位置被添加到包(培养基/ image1.png)
由于这一切都很复杂,我建议您使用Microsoft或其他库提供的OpenXML SDK 2.0,例如OpenXML4J。这些库,特别是来自微软的库,可以让你的工作变得更容易。
事情是我需要嵌入图像,但我想写尽可能少的数据 – agnieszka 2008-12-18 00:09:41