Text in word text boxes or in shapes not imported from word document

1 Answer 129 Views
WordsProcessing
Adrian
Top achievements
Rank 1
Iron
Adrian asked on 05 May 2023, 08:40 AM

Hi all,

 

I'm trying to import a word document as template, and change some text from this document with RadWordsProcessing in order to fill this document automatically.

In order to do that, I assume I must import the document as a RadFlowDocument and then change some text with the Replace method and finally export the modified document. But, when I import the word document and export it without any change, all text in text boxes or in shapes has disappeared. Is there any step or any configuration I missed?

Here is my code :

    RadFlowDocument document;
    DocxFormatProvider provider = new DocxFormatProvider();
    using (Stream input = File.OpenRead(myTemplateFilePath)
    {
        document = provider.Import(input);
    }

    //Change my text here with replace method
    //RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document); 
    //editor.ReplaceText("oldText",  "newText");

    IFormatProvider<RadFlowDocument> formatProvider = new DocxFormatProvider();
    using (FileStream stream = File.OpenWrite(myResultFilePath))
    {
        formatProvider.Export(document, stream);
    }

    Console.WriteLine("Document generated.");

 

Pictures of my template file and my result file are attached here.

 

Thank you in advance for your help,
Regards,

Adrian

1 Answer, 1 is accepted

Sort by
0
Accepted
Aleks
Telerik team
answered on 05 May 2023, 03:34 PM

Hi Adrian,

I have tried to replicate the case by adding shapes and textboxes in a blank docx file and I am getting the same results.

The behavior you are experiencing is most likely due to unsupported elements by the WordsProcessing library (public itembut I do not want to accidentally mislead you so would you be able to provide a sample document for examination?

I look forward to hearing from you.

Regards,
Aleks
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Adrian
Top achievements
Rank 1
Iron
commented on 15 May 2023, 07:36 AM

Hi Aleks,

 

Thank you for your answer and my apologies for my late reply.

Here is a sample document. But I think you have already given me the right explanation.

 

Thank you in advance for your help,
Regards,

Adrian

Aleks
Telerik team
commented on 15 May 2023, 11:40 AM

Hi Adrian,

I just checked your document and I am getting the same results as with my replicated case.

I can now confirm that the behavior you are experiencing is definitely due to unsupported elements by the WordsProcessing library (public item).

I remain at your disposal if you have any further questions.

Regards,
Aleks
Progress Telerik
Hugues
Top achievements
Rank 1
commented on 14 Feb 2024, 05:11 AM

Hi,

I'm faced with a similar situation and I wonder if the root cause is related to this. In my case, I import the document from Word with a cover page, including some textboxes, colors etc, and when I try to display the document in a RichTextEditor control, the cover page controls are not displayed at all.  A blank page is shown. After doing some research, it appears that the RichTextEditor control does not yet support content controls, but I'm not sure. Can you help clarify?

Thank you!

Dess | Tech Support Engineer, Principal
Telerik team
commented on 16 Feb 2024, 03:25 PM

Hi, Hugues,

According to the provided information, I suspect that you are referring to RadRichTextEditor from the UI for WinForms suite. Please correct me if I am wrong. 

Currently, RadRichTextEditor can import and export content controls from and to Office Open XML (docx) and XAML formats. When exporting to other formats the content controls will be lost, however, their content (current value) will be exported. Additional information is available in the following help article: Content Controls (Structured Document Tags).

In case you are facing any further difficulties, I would recommend you to submit a ticket for the respective product and provide the problematic file. Thus, the support engineers would gladly assist you.

Hugues
Top achievements
Rank 1
commented on 22 Feb 2024, 04:51 PM

Hi Dess,

You are correct. I am referring to the RadRichTextEditor from the UI. I'll submit a ticket! Thank you!

Tags
WordsProcessing
Asked by
Adrian
Top achievements
Rank 1
Iron
Answers by
Aleks
Telerik team
Share this question
or