开发者

Add image using WordML

I am trying to add an image into a document using WordML. I have used the开发者_C百科 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.

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

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 (download, rename from txt to xml and open with word)

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>

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

You might try docx4j instead :-)

See http://dev.plutext.org/svn/docx4j/trunk/docx4j/src/main/java/org/docx4j/samples/AddImage.java

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜