After deleting a custom annotation using the DeleteAnnotationRange method when there is a text immediately in front of the annotation start:
and then trying to delete the last character in this former annotation range an exception is thrown (Exception: System.InvalidOperationException: 'inline does not belong to this document.')
When "rFonts" is set in docDefaults:
<w:styles>
<w:docDefaults>
<w:rPrDefault>
<w:rPr>
<w:rFonts w:ascii="Verdana" w:eastAsia="Times New Roman" w:hAnsi="Verdana" w:cs="Verdana"/>
...
</w:rPr>
</w:rPrDefault>
and partially in the local run properties:
<w:r>
<w:rPr>
<w:rFonts w:cs="Times New Roman"/>
...
</w:rPr>
<w:t>Text</w:t>
</w:r>
A wrong font is applied.
Expected: Verdana
Actual: Times New Roman
In the Track Change mode, try to insert several images using standard InsertPictureCommand (or even Editor.InsertImage()) double enter and then again. Or insert text between already inserted images.
The error could be also observed when accepting all changes.
Hi,
This issue was referenced all the way back in 2017 in this post for Win Forms, but it appears it was never actually resolved; only a workaround was provided. I don't think this workaround will work for me, however, because I am binding to the RtfDataProvider in xaml and therefore it makes the changes to the document string before I am able to do a manual replacement of "rtf1" where it only had "rtf" for the version tag before. While changing the tag after the fact will fix the issue of it not being recognized in the other software we use, it still causes bloat because of the fact that it most cases it over triples the amount of raw text in the returned string when the textbox does not properly apply the rtf version tag.
Below is an example of the greatly enlarged amount of data before and after this error occurs:
"S11111^A^1^","{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Arial; } }\viewkind4\uc1 \f0\fs20 Measurements: \par \tab Neck to Fundus \tab \tab 1.5 cm \par \tab Diameter at Fundus \tab \tab 3.0 cm \par \tab Color \tab \tab \tab \tab Green-Tan \par \tab Wall Thickness \tab \tab 1.0 cm \par \tab Mucosa \tab \tab \tab Velvety \par \par No Cholesterolosis Is Identified \par \par No Bile Identified \par \par No Gallstones Are Identified \par \par Summary of Sections: \par \tab Received in Bag and Formalin. The cystic duct margin and representative sections of gallbladder fundus and body are submitted in 1 cassette. \par \par KG/sjh }"^""$$$"
"S11111^A^1^","{\rtf\ansi\ansicpg1252\uc1\deff0\deflang1033{\fonttbl{\f0 Verdana;}{\f1 Arial;}}{\colortbl\red0\green0\blue0 ;}{\*\defchp\ltrch\f0\fs20\i0\b0\strike0\cf0\ulc0\ulnone}{\*\defpap\sl276\slmult1\ql\sa180\ltrpar}{\stylesheet{\s0\sqformat\spriority0\ltrch\f0\fs20\i0\b0\strike0\cf0\ulc0\ulnone\sl276\slmult1\ql\sa180\ltrpar Normal;}{\*\ts2\tsrowd\spriority59\trbrdrt\brdrnone\trbrdrb\brdrnone\trbrdrl\brdrnone\trbrdrr\brdrnone\trbrdrh\brdrnone\trbrdrv\brdrnone\trgaph0\trpaddl75\trpaddr75\trpaddt0\trpaddb0\clpadft3\clpadt0\clpadfr3\clpadr0\clpadfl3\clpadl0\clpadfb3\clpadb0\tsvertalt\ltrch\f0\fs20\i0\b0\strike0\cf0\ulc0\ulnone\sl276\slmult1\ql\sa180\ltrpar Table Normal;}}\nouicompat\viewkind4\paperw12240\paperh15840\margl1425\margr1425\margt1425\margb1425\deftab720\sectd\pgwsxn12240\pghsxn15840\marglsxn1425\margrsxn1425\margtsxn1425\margbsxn1425\headery720\footery720\pard\sl240\slmult1\ql\ltrpar{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone Measurements: }{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone\par}\pard\sl240\slmult1\ql\ltrpar{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone \tab Neck to Fundus \tab \tab 1.6 cm }{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone\par}\pard\sl240\slmult1\ql\ltrpar{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone \tab Diameter at Fundus \tab \tab 3.0 cm }{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone\par}\pard\sl240\slmult1\ql\ltrpar{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone \tab Color \tab \tab \tab \tab Green-Tan }{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone\par}\pard\sl240\slmult1\ql\ltrpar{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone \tab Wall Thickness \tab \tab 1.0 cm }{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone\par}\pard\sl240\slmult1\ql\ltrpar{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone \tab Mucosa \tab \tab \tab Velvety }{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone\par}\pard\sl240\slmult1\ql\ltrpar{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone }{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone\par}\pard\sl240\slmult1\ql\ltrpar{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone No Cholesterolosis Is Identified }{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone\par}\pard\sl240\slmult1\ql\ltrpar{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone\par}\pard\sl240\slmult1\ql\ltrpar{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone No Bile Identified }{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone\par}\pard\sl240\slmult1\ql\ltrpar{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone\par}\pard\sl240\slmult1\ql\ltrpar{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone No Gallstones Are Identified }{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone\par}\pard\sl240\slmult1\ql\ltrpar{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone\par}\pard\sl240\slmult1\ql\ltrpar{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone Summary of Sections: }{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone\par}\pard\sl240\slmult1\ql\ltrpar{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone \tab Received in Bag and Formalin. The cystic duct margin and representative sections of gallbladder fundus and body are submitted in 1 cassette. }{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone\par}\pard\sl240\slmult1\ql\ltrpar{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone\par}\pard\sl240\slmult1\ql\ltrpar{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone KG/sjh }{\ltrch\f1\fs20\i0\b0\strike0\cf0\ulc0\ulnone\par}}"^""$$$"
If there is a way that I can use the workaround in that post to prevent this bloating of the data while still using my current setup with bindings, I would be happy to do so, but as it is I don't think that's the case. It seems like this is clearly a bug and something that should have a real fix on the control and not a workaround after all this time, but if that's not the case and it was left as is for a reason, I'd be happy to hear that reason.
Thanks in advance for the help.
The default styles are not copied when using the CreateDocumentFromSelection method.
Workaround: Manually copy the styles:
var document = radRichTextBox.Document.Selection.CreateDocumentFromSelection();
document.StyleRepository.Clear();
foreach (var item in radRichTextBox.Document.StyleRepository)
{
var style = new StyleDefinition(item);
document.StyleRepository.Add(style);
}