syncFucion.DOC.IO.WordDocument is not working for "Title Text" in Word Document in Turkish Letters(especially İ, ı)

Hi Dear Syncfusion Team;

I have an issue when I trying to find and replace certain words in the attached Word Document using DocIO. Certain turkish characters like "İ" does not show up when I save the document.

 Here are the steps to reproduce the same error and also I will share the code;

- Adding my Word Document as a Base64 format in FindAndReplaceController file,

- I'm converting from Base64 to byteArray my document,

- Adding in a Memory Stream object

Here is the code sample;

using WDocument = Syncfusion.DocIO.DLS.WordDocument;
using WFormatType = Syncfusion.DocIO.FormatType;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Syncfusion.DocIO.DLS;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using WDocument = Syncfusion.DocIO.DLS.WordDocument;
using WFormatType = Syncfusion.DocIO.FormatType;
using System.Text.RegularExpressions;
using System.Text;
using System.Security.Cryptography;








 public class ExportData
        {
            //Aranacak kelime
            public string Text2Search { get; set; }
            //Dosya Base64 formatında.
            public string DocumentData { get; set; }
            //Paragraf hash kodu
            public string IncomingHashCode { get; set; }
            //Aranacak kelime yerine yazılacak kelime.
            public string IncomingData { get; set; }
            //Verilen parametrede belirtilen benzer vaka metniyle eşleşmesi için true olarak ayarlayın;
            public bool CaseSensitive { get; set; }
            //Verilen parametrede belirtilen tüm sözcük metniyle eşleşmek için true olarak ayarlayın;
            public bool WholeWord { get; set; }
            public List<ParagraphTextChangeClass> ChangeRequests { get; set; }




        }








[Route("test")]
        public FileStreamResult FindAndReplace3([FromBody] ExportData exportData)
        {
            Byte[] data = (Convert.FromBase64String(exportData.DocumentData.Split(',')[1]));
            MemoryStream stream = new MemoryStream();




            stream.Write(data, 0, data.Length);
            var result1 = Regex.Replace(exportData.Text2Search.Trim('*').Trim(), "(İ|i|ı|I)", "(i|İ|ı|I)");
            Regex theRegex = new Regex(result1, RegexOptions.IgnoreCase | RegexOptions.Multiline);
            WDocument document = new WDocument(stream, WFormatType.Docx);




            TextSelection[] textSelections = document.FindAll(theRegex);
            WParagraph paragraph = null;
            for (int i = 0; i < textSelections.Length; i++)
            {
                WTextRange range = textSelections[i].GetAsOneRange();
                paragraph = range.OwnerParagraph;
                //var nextWanted = document.FindNext(paragraph, theRegex);
                //nextWanted.GetAsOneRange().Text = exportData.IncomingData;
                var replaced = "";
                var word2Search = Regex.Replace(exportData.Text2Search.Trim('*').Trim(), "(İ|i|ı|I)", "(i|İ|ı|I)", RegexOptions.IgnoreCase | RegexOptions.Multiline);




                replaced = Regex.Replace(paragraph.Text, word2Search, exportData.IncomingData, RegexOptions.IgnoreCase | RegexOptions.Multiline);
                paragraph.Text = replaced;




            }
            document.Save(stream, WFormatType.Docx);




            document.Close();




            stream.Position = 0;
            return File(stream, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "alper.docx");




        }


to style I've tried Times New Roman, Comic Sans and Arial in the Word Document but any font has not worked.


I am using Windows also you can find the packages and their versions in the attachment;


Attachment: files_41808b04.zip

4 Replies

MR Manikandan Ravichandran Syncfusion Team January 6, 2022 01:04 PM UTC

Hi Ulas,

We have reproduced the reported problem with “Text gets changed when open and save the Word document using DocIO” in our end and we suspect that it to be a defect. We will validate this issue and share the details on 10th January 2022.

Regards,
Manikandan Ravichandran 



UN Unknown replied to Manikandan Ravichandran January 7, 2022 12:19 PM UTC

Thank you for your reply,


i will be waiting for your solution,


I just want to add something about the issue;


As you can see from the 2 pictures in the attached file, they are inside the title cell.


If I open a word document and try to make changes, when I change one, the other automatically changes. same things as each other. When I use find and replace functions in DocIO, only the cell in the body of document changes as seen in the picture below. And cell is replaced with plain text. In other words, text is no more in the cell.


and as you can see, Turkish characters disappear. No matter what I do I can't change the title cell inside the header. Could you please take a look at this issue as well?


Best Regards.


Attachment: beforeafterfordocument_999257e5.zip



MR Manikandan Ravichandran Syncfusion Team January 10, 2022 03:02 PM UTC

Hi Ulas,

We have confirmed the reported issue with “Inline content control content not preserved properly while resaving DOCX format document” as a defect and we have logged a defect report for this issue. Since you are using the Weekly NuGet release (v19.3.0.48), we will include the fix in our upcoming Weekly NuGet release which will be available on 01st February 2022.

The status of this bug task can be tracked through the below feedback link:
https://www.syncfusion.com/feedback/31773/inline-content-control-content-not-preserved-properly-while-resaving-docx-format

Note: If you require a patch for the reported issue in any of our Essential Studio Main or SP release versions, then kindly let us know the version, so that we can provide a patch in that version based on our SLA policy.

Regards,
Manikandan Ravichandran 



MR Manikandan Ravichandran Syncfusion Team February 1, 2022 04:14 PM UTC

Hi Ulas,

We have included the fix for this issue in our 2021 Volume 4 SP release which was rolled out on yesterday and is available for download under the following link.

https://www.syncfusion.com/forums/172430/essential-studio-2021-volume-4-service-pack-release-v19-4-0-48-is-available-for-download

The status of this bug task can be tracked through the following link:
https://www.syncfusion.com/feedback/31773/inline-content-control-content-not-preserved-properly-while-resaving-docx-format

Regards,
Manikandan Ravichandran
 


Loader.
Up arrow icon