I have field definition in Word 2016 (Office 365 same problem) like this
<w:r>
<w:fldChar w:fldCharType="begin"/>
<w:instrText xml:space="preserve"> DOCPROPERTY "UohsDate" \* MERGEFORMAT </w:instrText>
<w:fldChar w:fldCharType="separate"/>
</w:r>
after filling field by docx4j, editing document in word and saving document again, my field definition is divided into two:
<w:r>
<w:instrText xml:space="preserve"> DOCPROPERTY "UohsDa</w:instrText>
</w:r>
<w:r>
<w:instrText xml:space="preserve">te" \* MERGEFORMAT </w:instrText>
</w:r>
<w:r>
<w:fldChar w:fldCharType="separate"/>
</w:r>
Please, any suggestions? Thanks a lot
Related
i am trying to create a Word Template, where Users put in notes with basic formating options (like Bullet List , indentations etc.). But i need that content as Richtext, to display it in a browser.
I thought the RichText ContentControl field would save its content as.. well Richtext. But it turns out to be ooxml.
Is there maybe some converter to convert a richtext field to actual richtext?
Currently its content looks like this:
<w:sdtContent>
<w:p>
<w:pPr>
<w:pStyle w:val="Listenabsatz" />
<w:ind w:left="4320" />
</w:pPr>
<w:proofErr w:type="spellStart" />
<w:r>
<w:t>Ztzjtzj</w:t>
</w:r>
<w:proofErr w:type="spellEnd" />
</w:p>
<w:p>
<w:pPr>
<w:pStyle w:val="Listenabsatz" />
<w:ind w:left="4320" />
</w:pPr>
<w:proofErr w:type="spellStart" />
<w:r>
<w:t>Tzjtzjtzj</w:t>
</w:r>
<w:proofErr w:type="spellEnd" />
</w:p>
</w:sdtContent>
I have a Word document with this style:
<w:style w:type="paragraph" w:customStyle="1" w:styleId="myStyle">
<w:name w:val="myStyle"/>
<w:basedOn w:val="ListParagraph"/>
<w:qFormat/>
<w:rsid w:val="005F5C84"/>
<w:pPr>
<w:widowControl/>
<w:numPr>
<w:numId w:val="1"/>
</w:numPr>
<w:suppressLineNumbers/>
<w:spacing w:before="240" w:line="360" w:lineRule="auto"/>
<w:ind w:left="0" w:firstLine="720"/>
<w:contextualSpacing w:val="0"/>
</w:pPr>
</w:style>
Because of the <w:suppressLineNumbers/> tag, I'd expect that Word would not show line numbers, but Word does show the line numbers.
How do I know when <w:suppressLineNumbers/> should take effect? I'm not finding any good documentation on this.
Below is the paragraph in case that helps.
<w:p ...>
<w:pPr>
<w:pStyle w:val="myStyle"/>
</w:pPr>
<w:r w:rsidRPr="00126430">
<w:t xml:space="preserve">Text</w:t>
</w:r>
</w:p>
Word line numbering is per Section, not per Style. Add or remove line numbers
It's possible to drop this into the XML for a paragraph to suppress the line numbering for that paragraph:
<w:pPr>
<w:suppressLineNumbers/>
</w:pPr>
But there's nothing analogous for use in a style. There's no online documentation for using that parameter in a style, either.
I need to compare two Word files and merge all insertions into a third one.
I have managed to do that with OpenXML-Power-Tools and WmlCompare, but how do I reject only deletions?
Accepting insertions is easy with OpenXmlPowerTools.RevisionAccepter but I can't get the rejection of deletions to work, that way I would get merged file without revisions.
Should I take this approach or would you suggest different approach?
Rules are:
1) Text can be added anywhere in the file.
2) Text is always added to file, never deleted.
3) Files have a .docx file extension
It is relatively easy to reject, or undo, deletions. So, say you have the following sample paragraph with one w:del element that wraps a deleted w:r element.
<w:p>
<w:r>
<w:t xml:space="preserve">This is </w:t>
</w:r>
<w:del w:id="0" w:author="Thomas Barnekow" w:date="2020-02-16T14:37:00Z">
<w:r>
<w:delText xml:space="preserve">deleted </w:delText>
</w:r>
</w:del>
<w:r>
<w:t>text.</w:t>
</w:r>
</w:p>
To reject the deletion, you need to unwrap the deleted w:r and turn the w:delText into a w:t again. Without any further processing (see below), the result of your rejecting the deletion would look like this:
<w:p>
<w:r>
<w:t xml:space="preserve">This is </w:t>
</w:r>
<w:r>
<w:t xml:space="preserve">deleted </w:delText>
</w:r>
<w:r>
<w:t>text.</w:t>
</w:r>
</w:p>
As an optional step, using the MarkupSimplifier of the Open XML PowerTools, you could also coalesce adjacent runs having identical formatting, which would result in the following markup:
<w:p>
<w:r>
<w:t>This is deleted text.</w:t>
</w:r>
</w:p>
When attempting to get the ooxml from the document I've found a variance.
In Windows, iPad, and Word Online in a document that has a cross reference that will break if you update it, but is not yet broken. (Meaning if you right click it and press update then it will go to to the "Error! Reference source not found." Then the xml will display the text value:
<w:r>
<w:fldChar w:fldCharType="begin"/>
</w:r>
<w:r>
<w:instrText xml:space="preserve"> REF _Ref274197646 \n \h </w:instrText>
</w:r>
<w:r>
<w:fldChar w:fldCharType="separate"/>
</w:r>
<w:bookmarkStart w:id="39" w:name="_Read0190056i"/>
<w:bookmarkStart w:id="40" w:name="_Read0190047i"/>
<w:r>
<w:t>(i)</w:t>
</w:r>
<w:bookmarkEnd w:id="39"/>
<w:bookmarkEnd w:id="40"/>
<w:r>
<w:fldChar w:fldCharType="end"/>
</w:r>
However in the Mac even though the screen is displaying the text, the xml shows the broken reference text.
<w:r>
<w:rPr>
<w:b/>
<w:bCs/>
</w:rPr>
<w:t>Error! Reference source not found.</w:t>
</w:r>
This feels like a bug, as the different versions of word should report the xml largely the same.
I have turned on the track changes(Revisions) option in word and made some changes and found all the track changes were being tracked and found in the openxml content. but i am not seeing the deleted listnum value in openxml content and the listnum values are continued from the next paragraph. so how can I track/get the deleted listnum value in openXml.
More details on the issue - we have 5 paragraphs with listnums (a) to (e). I turned on track changes and deleted listnum value (b) so that second paragraph has no listnum now. I thought I might get the value (b) in openxml since I turned on track changes but I am not able to get the deleted value (b) from openxml.
Thanks,
Manu
A single bulletpoint may use the following xml. It's a single Paragraph containing the text 'Item1' in a Run. The ParagraphProperties applies the style 'ListParagraph' and refers to a numbering:
<w:p>
<w:pPr>
<w:pStyle w:val="ListParagraph" />
<w:numPr>
<w:ilvl w:val="0" />
<w:numId w:val="1" />
</w:numPr>
</w:pPr>
<w:r>
<w:t>Item1</w:t>
</w:r>
</w:p>
If Track Changes is enabled and I delete the text 'Item1' I get xml like the following:
<w:p>
<w:pPr>
<w:pStyle w:val="ListParagraph" />
<w:pPrChange w:author="Daniel Brixen" w:date="2017-02-16T09:37:00Z" w:id="0">
<w:pPr>
<w:pStyle w:val="ListParagraph" />
<w:numPr>
<w:numId w:val="1" />
</w:numPr>
<w:ind w:hanging="360" />
</w:pPr>
</w:pPrChange>
</w:pPr>
<w:del w:author="Daniel Brixen" w:date="2017-02-16T09:37:00Z" w:id="2">
<w:r>
<w:delText>Item2</w:delText>
</w:r>
</w:del>
</w:p>
Two things to note:
The deleted text is in a DeletedRun-element
The change in paragraph-properties is recorded by a ParagraphPropertiesChange-element.
So you should be able to find the deleted text by using something like this:
using (var doc = WordprocessingDocument.Open(#"c:\temp\test.docx", true))
{
var deletedText = doc.MainDocumentPart.Document.Body.Descendants<DeletedText>();
Console.WriteLine(String.Join(" ", deletedText.Select(t => t.Text)));
}
Using Open XML Productivity Tool is helpful when debugging stuff like this.