I’m evaluating words, but I have some questions about the usability for us.
We want to build an webapplication where the user can upload a file
and then on the server there will be done some formatting and replace
- some words has to be formatted in italic (the font has to stay the same);
- sometimes words only has to change if it is in lowercase or uppercase, sometimes it doesn’t matter;
- sometimes the searchitem must be the whole word, sometimes it may be a part of a word;
- sometimes the searchitem has to have a specified style (like heading 1)
- the changes has to be trackable, so that the user can see in Word which things are changed
Is this possible?
Looking forward to your answer.
Aart van Assen
This message was posted using Email2Forum by alexey.noskov.
Thank you for your interest in Aspose.Words. Yes, you can use Aspose.Words to achieve all you need.
- You can use ReplaceEvaluator to change formatting of matched text. For example see the following code:
public void Test003()
// Open document
Document doc = new Document(@"Test003\in.doc");
// "word" will be bold and italic
Regex regex = new Regex("word");
doc.Range.Replace(regex, new ReplaceEvaluator(ReplaceInsertMergeField), false);
// Save output document
private ReplaceAction ReplaceInsertMergeField(object sender, ReplaceEvaluatorArgs e)
// Get MatchNode
Run run1 = (Run)e.MatchNode;
// Create Run
Run run2 = (Run)run1.Clone(true);
// Get index of match value
int index = run1.Text.IndexOf(e.Match.Value);
// split run that contains matched text
run2.Text = run1.Text.Substring(index + e.Match.Value.Length);
run1.Text = run1.Text.Substring(0, index);
// Create document builder
DocumentBuilder builder = new DocumentBuilder(e.MatchNode.Document);
// Move to run2
// Change font
builder.Font.Bold = true;
builder.Font.Italic = true;
// Insert value
Please see the following link to learn more about ReplaceEvaluator:
2. I think this could be controlled by regular expression you are using to match your word.
3. You can check style of matched item in ReplaceEvaluator.
4. Unfortunately, there no way to track changes made programmatically. This is a known issue #1121 in our defect database.
The issues you have found earlier (filed as WORDSNET-754) have been fixed in this .NET update and this Java update.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.