Store hidden attribute in .docx files
Posted:
Tue Sep 06, 2016 7:11 pm
by MatthiasH
Hello,
I develop an application that marks text in .docx documents with comments.
In order for a successive analysis to not apply the same comment again, I want to store the coveredText of the comment as well as the sentence hidden in the .docx comment. Note, these are two properties which – in my use case – identify an annotation.
How can I store attributes in the comment .docx XML that the user does not see?
Re: Store hidden attribute in .docx files
Posted:
Tue Sep 06, 2016 9:33 pm
by jason
I'm not entirely clear on your requirement, but you might be able to use a content control (set to can't be deleted) in the comment. Then, include your data either as hidden text, or better, in the content control's tag or linked custom xml.
You'll have to experiment in Word to see whether it "looks better" to have all of the comment content in the content control, or whether you can just put your data in it as hidden text and set it to can't be edited.
You can play with this stuff using Word's developer tab (which you'll have to make visible in Word's settings).
As a potential alternative approach, I just had a quick look at the Word 2012 commentsEx element, to see whether there is something there which it makes sense to use, but I don't think so...
Re: Store hidden attribute in .docx files
Posted:
Wed Sep 07, 2016 12:08 am
by MatthiasH
Imagine you want to store some data in a tag in your HTML to retrieve it later with JavaScript (e.g., data-hover="text when you hover over the HTML tag"). I think this is the best way to explain my requirement.
Can I add a custom tag to my comment?
- Code: Select all
<w:comment w:initials="RAT" w:author="Readability-Analysis-Tool" w:date="2016-09-06T09:34:29.737+02:00" w:id="0">
My approach for now is to put a hash code in the textId of the paragraph of the comment, e.g.
- Code: Select all
<w:comment w:initials="RAT" w:author="Readability-Analysis-Tool" w:date="2016-09-06T09:34:29.737+02:00" w:id="0">
<w:p textId="my-hash-code">
That should do the job. Thanks Jason!