OPEN XML add custom invisible data to paragraph / table

Is there a way to save additional data for the paragraph, which will be saved after the user opens and saves the document in MS Word.

I used CusotmXML for this, but it turns out that this is not possible for the journal, since MS-Word removes all CusotmXML elements from the document structure.

Each individual paragraph or table has an identifier that I would like to “pair” with my data source. Therefore, when I read docx again, I can determine the origin of each unchanged paragraph / table in the document.

+4
source share
3 answers

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

For instance:

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

See [MS-Docx] for details.

Also, check out the content controls that you can wrap around paragraphs and tables (or put in them). They have an ID property; they also allow you to store arbitrary text in the tag property. The string is limited to a length of approximately 120 characters.

0
source

a fairly flexible solution, but you get the idea by using a custom run for your data and hiding it from being displayed using Vanish

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

Adding Vanish to run properties will hide the run display, and you can use it to store user data without affecting the output of the document.

0
source

It might be possible to insert a SET field. This creates a bookmark in the document to which you can assign information. However, there is no way to protect him from the user deleting him. The DATA field is also possible.

Unlike “fade” (which, I believe, is equivalent to a “hidden” font), information will not be displayed if the user is used to display non-printed information. It will be displayed, however, if the user switches to field codes (Alt + F9).

0
source

Source: https://habr.com/ru/post/1497269/


All Articles