- Home
- Forum
- ASP.NET MVC
- Using document.Find not only to find the first result, but everything
Using document.Find not only to find the first result, but everything
I use this:
TextSelection textSelection = document.Find(findThis, false, false);
if (textSelection != null)
{
WTextRange text = textSelection.GetAsOneRange();
text.CharacterFormat.TextColor = Color.Red;
text.CharacterFormat.FontSize = 12;
text.CharacterFormat.UnderlineStyle = UnderlineStyle.Thick;
}
SIGN IN To post a reply.
5 Replies
TE
Testname
April 21, 2016 07:24 AM UTC
If I use document.Replace(findeDas, ersetzeDasProduktiv, false, false) he will replace everthing, but using TextSelection textSelection = document.Find(findThis, false, false); he will only find just one
VR
Vijay Ramachandran
Syncfusion Team
April 22, 2016 11:08 AM UTC
Hi,
Thank you for contacting Syncfusion support.
On further analysis with given details, we suspect you are trying to find all the words in a Word document using WordDocument.Find method. As per the behaviour of WordDocument.Find API, it will finds only the first occurrence in the document. If you want to find all the matching word in a document, you can use WordDocument.FindAll API, it will help you to find all the occurrence in the Word document.
Also you are using the WordDocument.Replace API to replace the text in Word document. As per the behaviour of this API, it will replace all the matches in Word document. If your requirement is only replacing first occurrence means you could make WordDocument.ReplaceFirst property as True before you using the WordDocument.Replace API, it will replace only the first occurrence in the Word document.
Please refer the following UG documentation link to know more about the Find and Replace functionality of DocIO.
http://help.syncfusion.com/file-formats/docio/working-with-find-and-replace
If we misunderstood any of your requirement then kindly elaborate the actual requirement with detailed description. Thereby we will analyse further on the mentioned case and will provided you appropriate solution.
Regards,
Vijay R
Thank you for contacting Syncfusion support.
On further analysis with given details, we suspect you are trying to find all the words in a Word document using WordDocument.Find method. As per the behaviour of WordDocument.Find API, it will finds only the first occurrence in the document. If you want to find all the matching word in a document, you can use WordDocument.FindAll API, it will help you to find all the occurrence in the Word document.
Also you are using the WordDocument.Replace API to replace the text in Word document. As per the behaviour of this API, it will replace all the matches in Word document. If your requirement is only replacing first occurrence means you could make WordDocument.ReplaceFirst property as True before you using the WordDocument.Replace API, it will replace only the first occurrence in the Word document.
Please refer the following UG documentation link to know more about the Find and Replace functionality of DocIO.
http://help.syncfusion.com/file-formats/docio/working-with-find-and-replace
If we misunderstood any of your requirement then kindly elaborate the actual requirement with detailed description. Thereby we will analyse further on the mentioned case and will provided you appropriate solution.
Regards,
Vijay R
TE
Testname
April 22, 2016 11:51 AM UTC
I used GetAsOneRange(); before to format a specific match, what should I use instead ?
My Code:
WTextRange text = textSelections.GetAsOneRange();//GetAsOneRange()
text.CharacterFormat.TextColor = Color.Red;
text.CharacterFormat.FontSize = 12;
text.CharacterFormat.UnderlineStyle = UnderlineStyle.Thick;
My Code:
WTextRange text = textSelections.GetAsOneRange();//GetAsOneRange()
text.CharacterFormat.TextColor = Color.Red;
text.CharacterFormat.FontSize = 12;
text.CharacterFormat.UnderlineStyle = UnderlineStyle.Thick;
TE
Testname
April 22, 2016 11:53 AM UTC
forget it I found the soulution
VR
Vijay Ramachandran
Syncfusion Team
April 25, 2016 07:27 AM UTC
Hi,
Thank you for your update.
Let us know if you have any other clarification.
Regards,
Vijay R
Thank you for your update.
Let us know if you have any other clarification.
Regards,
Vijay R
SIGN IN To post a reply.
- 5 Replies
- 2 Participants
-
TE Testname
- Apr 21, 2016 06:43 AM UTC
- Apr 25, 2016 07:27 AM UTC