Signal to the replace engine to do nothing because we have already done all what we wanted. Var builder = new DocumentBuilder(e.MatchNode.Document as ) īuilder.MoveTo((Run)runs) īuilder.InsertImage(_imageStream, _imageWidth, _imageHeight) Create Document Build-speller and insert text. SplitRun((Run)currentNode, remainingLength) Find all runs that contain parts of the match string. This array is used to store all nodes of the match for further removing. in this case it is necessary to split the run.ĬurrentNode = SplitRun((Run)currentNode, e.MatchOffset) The first (and may be the only) run can contain text before the match, This is a Run node that contains either the beginning or the complete match. ReplaceAction IReplacingCallback.Replacing(ReplacingArgs e) / This method replaces the match string, even if it spans multiple runs. / This method is called by the Aspose.Words find and replace engine for each match. Public ReplaceEvaluatorFindAndInsert(MemoryStream imageStream, Double imageWidth, Double imageHeight, SearchReplaceContentType replaceContentType) _replaceContentType = replaceContentType Public ReplaceEvaluatorFindAndInsert(string replaceContent, SearchReplaceContentType replaceContentType) / Initializes a new instance of the class. Private readonly SearchReplaceContentType _replaceContentType Private readonly MemoryStream _imageStream Private class ReplaceEvaluatorFindAndInsert : IReplacingCallback (new Regex(Regex.Escape(searchText), RegexOptions.IgnoreCase), string.Empty, replaceOptions) ReplaceOptions.ReplacingCallback = new ReplaceEvaluatorFindAndInsert(imageStream, imageWidth, imageHeight, replaceContentType) Public void Replace(string searchText, MemoryStream imageStream, Double imageWidth, Double imageHeight, SearchReplaceContentType replaceContentType) Old text cannot contain special characters. (new Regex(Regex.Escape(searchText), RegexOptions.IgnoreCase), replaceContent, replaceOptions) ReplaceOptions.Direction = FindReplaceDirection.Forward Public void Replace(string searchText, string replaceContent, SearchReplaceContentType replaceContentType)įindReplaceOptions replaceOptions = new FindReplaceOptions() New text can contain any special characters. Please see below for IReplacingCallback implementation code: public class ReplaceHelper Note: Created new ticket based on recommendation from this response PCF + libgdiplus on. Can you please share the supported MS word format when using ubuntu+aspose or PCF+aspose to understand the limitation of font and to get consistent look and feel of document templates.