简体   繁体   English

阻止Word 2010保存o:gfxdata base64或uuencoded VML?

[英]Prevent Word 2010 from saving o:gfxdata base64 or uuencoded VML?

I am working with .docx files containing several drawing canvases with images inserted and some lines and arrows drawn in Word 2010. I am using 2010 format with no compatibility mode. 我正在使用.docx文件,其中包含插入图像的几个绘图画布以及Word 2010中绘制的一些线条和箭头。我使用的是2010格式,没有兼容模式。

Word inserts an o:gfxdata attribute into each v:shape and v:group element and fills it with ascii encoded something. Word将o:gfxdata属性插入到每个v:shapev:group元素中,并使用ascii编码的东西填充它。 From what I have read it may be a copy of the VML describing the v:shape or v:group . 根据我的阅读,它可能是描述v:shapev:group的VML的副本。 I don't know if I just don't know what to look for, but I cannot determine what this data is for as its removal has no apparent effect on my ability to read or edit the document in Word 2003, 2007, or 2010. 我不知道我是否只是不知道该寻找什么,但我无法确定这些数据是什么,因为它的删除对我在Word 2003,2007或2010中阅读或编辑文档的能力没有明显影响。

It does swell the document.xml to almost twice the (apparent) necessary size. 它会使document.xml膨胀到几乎两倍(明显的)必要大小。 This considerably slows OpenTBS' processing so I would like to remove it, if possible. 大大减慢了OpenTBS的处理速度,所以如果可能的话我想删除它。 Does anyone know of a way to tell Word 2010 to quit saving this extra data? 有谁知道告诉Word 2010退出保存这些额外数据的方法? Or what it is for? 或者它是为了什么? I have really struggled to find any documentation on it beyond this post . 除了这篇文章,我真的很难找到任何关于它的文档。

Edit: 编辑:

Here is a sample .docx . 这是一个示例.docx The document.xml is ~141KB and OpenTBS takes an average of 10.35 seconds to create a file that includes this as a subtemplate 21 times. document.xml大约为141KB,OpenTBS平均需要10.35秒才能创建一个包含21次子模板的文件。 If I remove all of the o:ogfxdata attributes, the file size is reduced to ~37KB and OpenTBS takes only 2.99 seconds to produce the same file. 如果删除所有o:ogfxdata属性,文件大小将减少到~37KB,而OpenTBS只需2.99秒即可生成相同的文件。

Edit 2: 编辑2:

After further investigation, it appears the removal of the o:gfxdata may cause Word 2003 with an older Compatibilty Pack installed, to object to the file with the following error: 进一步调查后,似乎删除o:gfxdata可能会导致Word 2003安装较旧的Compatibilty Pack,以反对该文件,并出现以下错误:

"This is a pre-release version of the Compatibility Pack and can open pre-release Office 2007 files only. Do you want to check for a newer version of the Compatibility Pack?" “这是兼容包的预发行版本,只能打开预发布的Office 2007文件。是否要检查兼容包的更新版本?”

I have been able to open the file by installing a newer compatibility pack - though it prompts the user about the incompatibility and converts the file in order to open it. 我已经能够通过安装更新​​的兼容包来打开文件 - 虽然它会提示用户有关不兼容性并转换文件以便打开它。 This does not damage my file, but it is something to look out for. 这不会损坏我的文件,但需要注意的事项。

Attribute o:ogfxdata is poorly documented in the web. 属性o:ogfxdata在Web中记录不足。 According to your investigations, it's some kind of compatibility extra information. 根据您的调查,这是一种兼容性附加信息。

You can delete those attributes in your template using OpenTBS. 您可以使用OpenTBS删除模板中的这些属性。 The cleaning can be done once on your template without any merging, and then save the cleaned template as a new template. 清理可以在模板上完成一次而不进行任何合并,然后将清理后的模板另存为新模板。 Or you can perform the cleaning each time you open the template. 或者,您可以在每次打开模板时执行清洁。

Cleaning the DOCX file: 清理DOCX文件:

while ($x = clsTbsXmlLoc::FindStartTagHavingAtt($TBS->Source, 'o:gfxdata', 0) ) {
  $x->ReplaceAtt('o:gfxdata', '');
  $TBS->Source = str_replace(' o:gfxdata=""', '', $TBS->Source);
}

Note that the class clsTbsXmlLoc is provided with OpenTBS and is undocumented. 请注意,类clsTbsXmlLoc随OpenTBS clsTbsXmlLoc提供,并且未记录。 The code should work since OpenTBS 1.8.0. 代码应该从OpenTBS 1.8.0开始工作。 (which is currently in stable beta version). (目前处于稳定的测试版)。

I've noticed that since attributes o:gfxdata are deleted, they do not come back immediately when you edit the docx. 我注意到,由于属性o:gfxdata被删除,因此在编辑docx时它们不会立即返回。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM