Unplanned
Last Updated: 12 Feb 2024 11:36 by Joshua
DocxFormatProvider: Persist run properties (rPr) for the start of FieldCharacter.
Unplanned
Last Updated: 12 Feb 2024 10:56 by Uwe

PdfFormatProvider: Tab stop distance different from the default is not exported correctly.

Workaround: Use spaces instead.

Completed
Last Updated: 21 Mar 2024 05:53 by ADMIN
Release 2024.1.305 (2024 Q1)

Styles with names only different in spaces are treated as one.

Workaround:

var rtf = File.ReadAllText(fileName);
rtf = this.RenameStyleDifferentInOnlySpaces(rtf);
var document = provider.Import(rtf);

...

private string RenameStyleDifferentInOnlySpaces(string rtf)
{
    HashSet<string> styles = new HashSet<string>();

    string pattern = @"{\\(?:\*\\c)?s([0-9]+)[^}]*\n?[^}]*\\[^' ]* ?'?([^;]*)";

    var matches = Regex.Matches(rtf, pattern);
    foreach (Match match in matches)
    {
        string styleName = match.Groups[2].Value.Replace(" ", string.Empty);
        if (styles.Contains(styleName))
        {
            styleName = this.ReplaceOldStyleName(ref rtf, styles, match).Replace(" ", string.Empty);
        }

        styles.Add(styleName);
    }

    return rtf;
}

private string ReplaceOldStyleName(ref string rtf, HashSet<string> styles, Match match)
{
    string oldStyleName = match.Groups[2].Value;
    StringBuilder styleNameBuilder = new StringBuilder(oldStyleName + "0");
    while (styles.Contains(styleNameBuilder.ToString().Replace(" ", string.Empty)))
    {
        styleNameBuilder.Append("0");
    }

    string oldMatch = match.Groups[0].Value;
    string newMatch = oldMatch.Replace(oldStyleName, styleNameBuilder.ToString());
    rtf = rtf.Replace(oldMatch, newMatch);
    return styleNameBuilder.ToString();
}

Completed
Last Updated: 14 Mar 2024 08:59 by ADMIN
Release 2024.1.305 (2024 Q1)

StackOverflowException when importing a document with style based on itself.

Use the following code to strip the faulty "based on" definition from the RTF:

RtfFormatProvider provider = new RtfFormatProvider();
var rtf = File.ReadAllText(ofd.FileName);
rtf = this.ReplaceSelfBasedOnStyle(rtf);
this.flowDocument = provider.Import(rtf);

...

private string ReplaceSelfBasedOnStyle(string rtf)
{
    string pattern = @"{[\n]*\\s[0-9]+[^;]* \\\w* (Normal);}";

    var matches = Regex.Matches(rtf, pattern);
    foreach (Match match in matches)
    {
        string oldValue = match.Value;
        string newValue = oldValue.Replace(@"\sbasedon0 ", string.Empty);

        rtf = rtf.Replace(oldValue, newValue);
    }

    return rtf;
}

Unplanned
Last Updated: 02 Feb 2024 12:54 by Joshua

When a document containing a field without a separator is inserted using the RadFlowDocumentEditor.InsertDocument(*) method, the following error is thrown: 

System.InvalidOperationException: 'Start and end inlines should belong to paragraph in one block container.'

Workaround: 

        static void Main(string[] args)
        {
            DocxFormatProvider _DocXProvider = new DocxFormatProvider();
            string outputFile = $@"..\..\MergedResult.docx";
            File.Delete(outputFile); 

            RadFlowDocument target = _DocXProvider.Import(File.ReadAllBytes(@"..\..\HeaderFooter.docx"));
            RadFlowDocument source = _DocXProvider.Import(File.ReadAllBytes(@"..\..\SubHeaderFooter.docx"));
            RadFlowDocument contentSource = _DocXProvider.Import(File.ReadAllBytes(@"..\..\ContentOnly.docx"));

            MergeHeaders(target, source);
            MergeFooters(target, source);


            MergeContent(target, source);
            MergeContent(target, contentSource);
            System.IO.File.WriteAllBytes(outputFile, _DocXProvider.Export(target));
            Process.Start(outputFile);
        }

        private static void MergeContent(RadFlowDocument target, RadFlowDocument source)
        {
            DocumentElementImporter importer = new DocumentElementImporter(target, source, ConflictingStylesResolutionMode.UseTargetStyle);

            foreach (Telerik.Windows.Documents.Flow.Model.Section section in source.Sections)
            {
                foreach (BlockBase block in section.Blocks)
                {
                    BlockBase importBlock = importer.Import(block);
                    target.Sections.Last().Blocks.Add(importBlock);
                }
            }
        }

        private static void MergeHeaders(RadFlowDocument target, RadFlowDocument source)
        {
            Header targetHeader = target.Sections.First().Headers.Default;
            Header sourceHeader = source.Sections.First().Headers.Default;

            DocumentElementImporter importer = new DocumentElementImporter(target, source, ConflictingStylesResolutionMode.UseTargetStyle);
            foreach (BlockBase block in sourceHeader.Blocks)
            {
                BlockBase importedBlock = importer.Import(block);
                targetHeader.Blocks.Add(importedBlock);
            }
        }

        private static void MergeFooters(RadFlowDocument target, RadFlowDocument source)
        {
            Footer targetFooter = target.Sections.First().Footers.Default;
            Footer sourceFooter = source.Sections.First().Footers.Default;

            DocumentElementImporter importer = new DocumentElementImporter(target, source, ConflictingStylesResolutionMode.UseTargetStyle);
            int i = 0;
            foreach (BlockBase block in sourceFooter.Blocks)
            {
                BlockBase importedBlock = importer.Import(block);
                targetFooter.Blocks.Insert(i++, importedBlock);
            }
        }

 

Completed
Last Updated: 14 Mar 2024 08:59 by ADMIN
Release 2024.1.305 (2024 Q1)
HtmlFormatProvider: Paragraph property AutomaticSpacingBefore is set to true instead of false.
Completed
Last Updated: 02 Aug 2024 11:09 by ADMIN
Release 2024.3.802 (2024 Q3)
DocFormatProvider: EndOfStreamException when importing document with specific image.
Unplanned
Last Updated: 29 Jan 2024 16:58 by ADMIN
Styles defined in a glossary part overwrites the styles defined in the main document part.
Unplanned
Last Updated: 23 Jan 2024 13:05 by Amit

When a cell is removed due to having no content its table cell borders are not transferred to neighboring cell.

When a table cell contains a paragraph with no runs it is stripped from the document. However, its table cell borders should be transferred/reapplied to its neighboring cell to maintain consistency.

Unplanned
Last Updated: 10 Jan 2024 14:48 by Jennifer

Run the attached sample project. The available Doc1.docx contains an image place holder with borders around all sides. After inserting an image in the place holder, some of the borders are overlapping with the image:

The expected result is to have the borders around all sides:

Completed
Last Updated: 21 Mar 2024 05:53 by ADMIN
Release 2024.1.305 (2024 Q1)

Handle import of documents with self-referring styles.

As a workaround, you can go through the RTF document structure of a single file and utilize Regex to resolve the self-referring styles like this:

string rtf = File.ReadAllText("inputFile.rtf");
rtf = FixSelfReferringStyles(rtf);

Telerik.Windows.Documents.Flow.FormatProviders.Rtf.RtfFormatProvider provider = new Telerik.Windows.Documents.Flow.FormatProviders.Rtf.RtfFormatProvider(); 

 var document = provider.Import(rtf);

...

private static string FixSelfReferringStyles(string rtf)
{
    string regexString = @"{\\s([0-9]+)[^}]*\\slink([0-9]+)";

    var matches = Regex.Matches(rtf, regexString);
    foreach (Match match in matches)
    {
        if (match.Groups[1].Value == match.Groups[2].Value)
        {
            var oldValue = match.Groups[0].Value;
            var newValue = oldValue.Replace(@" \slink" + match.Groups[1].Value, string.Empty);
            rtf = rtf.Replace(oldValue, newValue);
        }
    }

    return rtf;
}

 

Unplanned
Last Updated: 02 Jan 2024 07:47 by Muhammad

Workaround:

Setting the IsDirty property of the FiledInfo object to "true" in order to recalculate layout and update the fields when the document is opened in a viewer:
var fieldInfo = editor.InsertField("TOC");
fieldInfo.UpdateField();
fieldInfo.IsDirty = true;
Unplanned
Last Updated: 27 Dec 2023 07:06 by Sashi
When importing a document containing a Picture SDT with TextProperties an exception is thrown: StructuredDocumentTags.Builders.SdtBuilderFailureException: 'This content control type cannot be inserted around a selected image.'
Unplanned
Last Updated: 22 Dec 2023 09:35 by Avrohom Yisroel
Unplanned
Last Updated: 19 Dec 2023 16:04 by Anthony

Merging (with RadFlowDocumentEditor's InsertDocument method) documents containing lists sometimes doesn't properly resolve the ListId properties.

Workaround: Removing the list with bullets resolves the issue as there is only one ListId to pick from:

document.Lists.Remove(1); 

 

Unplanned
Last Updated: 15 Dec 2023 17:53 by Anthony
An additional blank page is added when a page break is followed by a paragraph with enabled PageBreakBefore.
Unplanned
Last Updated: 08 Dec 2023 15:02 by Prabhu
When there is underline or strikethrough set to a bullet/number in docx, when this document is imported and then exported to HTML the entire paragraph is with underline/strikethrough.
Unplanned
Last Updated: 08 Dec 2023 14:51 by Prabhu

When there is a document (e.g. docx) with hanging indent in a list and this document is imported and then exported to HTML, the text overlaps the bullet as shown in the screenshot.

Completed
Last Updated: 11 Jan 2024 08:24 by ADMIN
Release 2024 Q1
PdfFormatProvider: Inline image surrounded by bookmarks is incorrectly measured when the document contains numbering fields.
Unplanned
Last Updated: 16 Nov 2023 13:14 by Deltaohm

Importing a document containing a hyperlink (<a>) tag without content extends it over the trailing elements.

For example, importing this HTML:

<a></a>
<p>First paragraph</p>
<p>Second paragraph</p>
<p>Third paragraph</p>

Generates:

Instead of this: