Hi,
I have a fairly complex docx file, in which I want to replace some text using the ReplaceText method, and managed to do so, until today, when I tried to insert a newline into my "new text". To be more specific
Old text: "lorem ipsum VAR_TEXT".
Using: editor.ReplaceText("VAR_TEXT", "dolor"), it works, and the output is "lorem ipsum dolor", as expected.
Now I want to do this: editor.ReplaceText("VAR_TEXT", "dolor \n\r sit amet"), and achieve:
lorem ipsum dolor
sit amet
but what I always get is lorem ipsum dolor sit amet
I also tried with: Environment.NewLine, \n, \n\r, \r\n, <br>, <br />, <w:br /> ...all failed.
Can you please help me out? Thank you!
11 Answers, 1 is accepted
A new line in the document you could insert using the Break element. At this point, the Find and Replace API of RadWordsProcessing performs a text-based search and allows you replace only (with) text values. Therefore, only string values are supported when replacing.
We already have a feature request to implement a Find functionality that will allow you position RadFlowDocumentEditor based on the results of the search and insert the desired element on this position. You could vote for this and track the feature's progress through the related public item in our feedback portal.
Hope this information is helpful.
Regards,
Tanya
Telerik by Progress
Hello,
Yes, the Find functionality, combined with the Break element would fix my issue. I guess I will wait for that to be implemented.
Thank you for your answer!
Hi Tanya,
Is replace text to new line now works with latest version? e.g. editor.ReplaceText("<BR>", code for newLine)
If yes, whats the code for new line?
Thanks!
Hi,
I see that the feature request for the find functionality as detailed at the following URL has been approved.
https://feedback.telerik.com/Project/184/Feedback/Details/176879-wordsprocessing-implement-find-search-functionality
Can you tell me whether it has been implemented and is available yet?
Kind regards,
Dominic.
The "Approved" status of an item means that it is included in our planning and prioritization processes. However, the task is not scheduled at this point and I cannot say when it might be implemented. Please, make sure to cast your vote for the implementation and subscribe to the item so you can receive notifications about status changes on it.
Regards,
Tanya
Progress Telerik
Hi team,
Does the implementation of replacing the text of multi line or text containing (Environment.NewLine) has been implmented or not?
Could you please give an alternative for the same.
Thanks in advance :)
The task concerning the replacement of text with other document elements is currently not implemented. You can vote for it as well as subscribe to track its status using the following feedback item: Introduce a way to replace text with other document elements. In the description of this item, you will also find a sample code allowing you to achieve a similar scenario.
Hope this is helpful.
Regards,
Tanya
Progress Telerik