使用WordML添加图像 [英] Add image using WordML

查看:94
本文介绍了使用WordML添加图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用WordML将图像添加到文档中.我已经从这里的jpg示例中使用了xml作为基础, http://www.codeproject .com/KB/office/WordML.aspx .我设法编写了Java,可以在文档中创建此确切的xml(wordML),但是当我尝试在MS Word 2007中打开生成的文件时,它说该文件无效或损坏.

I am trying to add an image into a document using WordML. I have used the xml as a basis from the jpg example from here http://www.codeproject.com/KB/office/WordML.aspx. I have managed to write Java which creates this exact xml(wordML) in the document, however when I try and open the generated file in MS Word 2007 it says the file in invalid or corrupt.

无法打开的文档的xml在这里:

The xml for the document that won't open is here:

http://pastebin.com/RNEkbvYG (原始xml) 抱歉,对于长粘贴,这是我能创建的最短的示例,顶部和底部都充满了树胶,但是您可以清楚地看到中间的数据图像.

http://pastebin.com/RNEkbvYG (Raw xml) Sorry for the long paste, this is the shortest example I could create, there's load of gumph at the top and bottom, but you can clearly see the data image in the middle.

http://pastebin.com/download.php?i=RNEkbvYG (下载,从txt重命名为xml,然后用word打开)

http://pastebin.com/download.php?i=RNEkbvYG (download, rename from txt to xml and open with word)

如果有人能看一下上面链接中的xml,看看他们是否能看到它为什么不能以文字形式打开,我将不胜感激.

I would greatly appreciate if anybody could look at the xml at the link above and see if they can see why it won't open in word.

推荐答案

<w:pict>
            <w:binData w:name="wordml://02000001.jpg">/9j/4AA..Xof/9k=</w:binData>
            <v:shape id="_x0000_i1025" style="width:100%;height:auto" type="#_x0000_t75">
              <v:imagedata o:title="network" src="wordml://02000001.jpg"/>
            </v:shape>
          </w:pict>

是2003 WordML.没有采用2007年docx格式/ECMA标准的w:binData元素.

is 2003 WordML. There is no w:binData element in the 2007 docx format / ECMA standard.

您可以改用docx4j :-)

You might try docx4j instead :-)

请参见 http ://dev.plutext.org/svn/docx4j/trunk/docx4j/src/main/java/org/docx4j/samples/AddImage.java

这篇关于使用WordML添加图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆