更改 XML 的 docx 以从网络加载图像

Changing XML of docx to load images from web

基本上,我的 docx 文件很大,里面有很多图片,我想减小它的大小,我尝试了一切,压缩图片等等,所以我从 25MB 到 13MB。但我想降低它更多,所以我在玩,我将 docx 扩展名更改为 zip 并解压缩它,看到文件的内容,看到图像,所以我将图像上传到我的网络托管和xml 文件,有一个文件正在调用图像。

 <?xml version="1.0" encoding="UTF-8" standalone="true"?>
-<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
 <Relationship Target="media/image99.jpeg" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Id="rId117"/>
 <Relationship Target="media/image273.png" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Id="rId299"/>
 <Relationship Target="media/image13.png" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Id="rId21"/>

所以我将 "Target" 更改为我的站点,例如:

 <Relationship Target="http://example.com/imagesfordoc/image13.png" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Id="rId21"/>

所以我确实用替换功能更改了所有这些,它们与示例中的完全一样(显然具有不同的图像名称)。我删除了不需要的媒体文件夹,然后又删除了它,然后又将扩展名从 zip 更改为 docx,运行 它给我错误,文件已损坏,然后我单击确定,然后它询问我要恢复,如果我单击是,它会按原样打开 word 文档,但没有图像(只是文本及其之前设置的样式)

图像已上传并在普通浏览器上完美打开,但当我打开 docx 时。出现错误!

知道如何实现吗?

从这里找到答案:http://blogs.msdn.com/b/dmahugh/archive/2006/12/10/images-in-open-xml-documents.aspx

需要添加参数:

 TargetMode="External"