We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

DocIO capabilities

I am evaluating DocIO for my application. The central feature for me is search and replace.

I've gotten DocIO to do search and replace while preserving formatting, however I need to search and replace the formatting itself (i.e. color). Is this possible?

I also need to be able to preserve instances where the first letter is capitalized. Can this be done as well?

Thanks in advance for any help you can give me.

Regards,
Ian



3 Replies

BP Bhuvaneswari P Syncfusion Team June 16, 2008 07:16 AM UTC

Hi,

Thanks for evaluating Syncfusion products.

Currently we do have option to find the text alone and we don't have support to find the formatting. However, we can workaround this issue by enumerating all the paragraphs and check its color and then change the color. Please find the below code snippet:

[C#]


foreach (WSection sec in document.Sections)
{
foreach (WParagraph par in sec.Paragraphs)
{
if (par.ChildEntities.Count > 0)
{
//Find the text based on the color
WTextRange range; range = (par[0] as ParagraphItem) as WTextRange;

if (range.CharacterFormat.TextColor == Color.FromArgb(255,255,0,255) )
{
//Change the color
range.CharacterFormat.TextColor = Color.Brown;
}
}

}

Here is the sample for your reference:
http://websamples.syncfusion.com/samples/DocIO.Windows/P74470/main.htm

Please let me know if you have any other questions.

Best Regards,
Bhuvana




IH Ian Hughes June 16, 2008 05:57 PM UTC

Hi Bhuvana,

Actually I need to change individual word and phrase color. I see that DocIO has the concept of WTextRange. Is it possible to do something like, "Find, select, set wtextrange to selection, change color property, find next?"

If possible, that would do work if it was reasonably fast, something that doesn't seem to be a problem with string search and replace.

Regards and thanks for the quick reply,
Ian

>I am evaluating DocIO for my application. The central feature for me is search and replace.

I've gotten DocIO to do search and replace while preserving formatting, however I need to search and replace the formatting itself (i.e. color). Is this possible?

I also need to be able to preserve instances where the first letter is capitalized. Can this be done as well?

Thanks in advance for any help you can give me.

Regards,
Ian






RS Rajkumar S Syncfusion Team June 24, 2008 10:04 AM UTC

Hi,

Thanks for the update.

We don't have any direct option to find and replace the format alone. As a workaround we can find the text and change the format using the text range like below code snippets:

[C#]

//Find the text
TextSelection seletion = document.Find("text");
//Assign the selected text range
WTextRange[] range= seletion.GetRanges();
//Format the text range
range[0].CharacterFormat.TextColor=Color.green;


Please try the above code and let me know if this helps you.

Regards ,
Rajkumar.



Loader.
Live Chat Icon For mobile
Up arrow icon