OPEN XML add custom not visible data to paragraph/table

两盒软妹~` 提交于 2019-12-05 16:14:19

A possibility would be to insert a SET field. This creates a bookmark in the document to which you can assign information. There's no way to protect it from the user removing it, however. A DATA field might also be a possibility.

Unlike "vanish" (which I believe is equivalent to "hidden" font format) the information would not display if the user is in the habit of displaying non-printing information. It will display, however, if the user toggles on field codes (Alt+F9).

You can have a divId on a paragraph, and in xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" there are attributes w14:textId and w14:paraId.

For example:

<w:p w14:textId="81a184ad" w14:paraId="81a184ad" >
  <w:pPr>
    <w:divId w:val="124349312"/>

See [MS-Docx] for details.

Alternatively, have a look at content controls, which you can wrap around paragraphs and tables (or put inside them). These have an ID property; they also let you store arbitrary text in their tag property. The string is limited in length to something like 120 chars.

A rather noddy solution, but have you cosidered using a custom run for your data and hiding it from displaying using Vanish

<w:rPr>
   <w:vanish />
</w:rPr>

Adding vanish to run properties will hide the run from displaying and you might use this to store custom data with out affecting the output of the document.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!