ReplaceToImages
ReplaceToImages(string, ImageSaveOptions, string, string, FindReplaceOptions)
Replaces all occurrences of a specified character string pattern with a replacement string in the input file. Renders output to images.
public static Stream[] ReplaceToImages(string inputFileName, ImageSaveOptions saveOptions,
string pattern, string replacement, FindReplaceOptions options = null)
Parameter | Type | Description |
---|---|---|
inputFileName | String | The input file name. |
saveOptions | ImageSaveOptions | The save options. |
pattern | String | A string to be replaced. |
replacement | String | A string to replace all occurrences of pattern. |
options | FindReplaceOptions | FindReplaceOptions object to specify additional options. |
Examples
Shows how to replace string in the document and save result to images.
// There is a several ways to replace string in the document:
string doc = MyDir + "Footer.docx";
string pattern = "(C)2006 Aspose Pty Ltd.";
string replacement = "Copyright (C) 2024 by Aspose Pty Ltd.";
Stream[] images = Replacer.ReplaceToImages(doc, new ImageSaveOptions(SaveFormat.Png), pattern, replacement);
FindReplaceOptions options = new FindReplaceOptions();
options.FindWholeWordsOnly = false;
images = Replacer.ReplaceToImages(doc, new ImageSaveOptions(SaveFormat.Png), pattern, replacement, options);
See Also
- class ImageSaveOptions
- class FindReplaceOptions
- class Replacer
- namespace Aspose.Words.LowCode
- assembly Aspose.Words
ReplaceToImages(Stream, ImageSaveOptions, string, string, FindReplaceOptions)
Replaces all occurrences of a specified character string pattern with a replacement string in the input file. Renders output to images.
public static Stream[] ReplaceToImages(Stream inputStream, ImageSaveOptions saveOptions,
string pattern, string replacement, FindReplaceOptions options = null)
Parameter | Type | Description |
---|---|---|
inputStream | Stream | The input file stream. |
saveOptions | ImageSaveOptions | The save options. |
pattern | String | A string to be replaced. |
replacement | String | A string to replace all occurrences of pattern. |
options | FindReplaceOptions | FindReplaceOptions object to specify additional options. |
Examples
Shows how to replace string in the document using documents from the stream and save result to images.
// There is a several ways to replace string in the document using documents from the stream:
string pattern = "(C)2006 Aspose Pty Ltd.";
string replacement = "Copyright (C) 2024 by Aspose Pty Ltd.";
using (FileStream streamIn = new FileStream(MyDir + "Footer.docx", FileMode.Open, FileAccess.Read))
{
Stream[] images = Replacer.ReplaceToImages(streamIn, new ImageSaveOptions(SaveFormat.Png), pattern, replacement);
FindReplaceOptions options = new FindReplaceOptions();
options.FindWholeWordsOnly = false;
images = Replacer.ReplaceToImages(streamIn, new ImageSaveOptions(SaveFormat.Png), pattern, replacement, options);
}
See Also
- class ImageSaveOptions
- class FindReplaceOptions
- class Replacer
- namespace Aspose.Words.LowCode
- assembly Aspose.Words
ReplaceToImages(string, ImageSaveOptions, Regex, string, FindReplaceOptions)
Replaces all occurrences of a specified regular expression pattern with a replacement string in the input file. Renders output to images.
public static Stream[] ReplaceToImages(string inputFileName, ImageSaveOptions saveOptions,
Regex pattern, string replacement, FindReplaceOptions options = null)
Parameter | Type | Description |
---|---|---|
inputFileName | String | The input file name. |
saveOptions | ImageSaveOptions | The save options. |
pattern | Regex | A regular expression pattern used to find matches. |
replacement | String | A string to replace all occurrences of pattern. |
options | FindReplaceOptions | FindReplaceOptions object to specify additional options. |
Examples
Shows how to replace string with regex in the document and save result to images.
// There is a several ways to replace string with regex in the document:
string doc = MyDir + "Footer.docx";
Regex pattern = new Regex("gr(a|e)y");
string replacement = "lavender";
Stream[] images = Replacer.ReplaceToImages(doc, new ImageSaveOptions(SaveFormat.Png), pattern, replacement);
images = Replacer.ReplaceToImages(doc, new ImageSaveOptions(SaveFormat.Png), pattern, replacement, new FindReplaceOptions() { FindWholeWordsOnly = false });
See Also
- class ImageSaveOptions
- class FindReplaceOptions
- class Replacer
- namespace Aspose.Words.LowCode
- assembly Aspose.Words
ReplaceToImages(Stream, ImageSaveOptions, Regex, string, FindReplaceOptions)
Replaces all occurrences of a specified regular expression pattern with a replacement string in the input file. Renders output to images.
public static Stream[] ReplaceToImages(Stream inputStream, ImageSaveOptions saveOptions,
Regex pattern, string replacement, FindReplaceOptions options = null)
Parameter | Type | Description |
---|---|---|
inputStream | Stream | The input file stream. |
saveOptions | ImageSaveOptions | The save options. |
pattern | Regex | A regular expression pattern used to find matches. |
replacement | String | A string to replace all occurrences of pattern. |
options | FindReplaceOptions | FindReplaceOptions object to specify additional options. |
Examples
Shows how to replace string with regex in the document using documents from the stream and save result to images.
// There is a several ways to replace string with regex in the document using documents from the stream:
Regex pattern = new Regex("gr(a|e)y");
string replacement = "lavender";
using (FileStream streamIn = new FileStream(MyDir + "Replace regex.docx", FileMode.Open, FileAccess.Read))
{
Stream[] images = Replacer.ReplaceToImages(streamIn, new ImageSaveOptions(SaveFormat.Png), pattern, replacement);
images = Replacer.ReplaceToImages(streamIn, new ImageSaveOptions(SaveFormat.Png), pattern, replacement, new FindReplaceOptions() { FindWholeWordsOnly = false });
}
See Also
- class ImageSaveOptions
- class FindReplaceOptions
- class Replacer
- namespace Aspose.Words.LowCode
- assembly Aspose.Words