replace_to_images method
Contents
[
Hide
]replace_to_images(input_file_name, save_options, pattern, replacement)
Replaces all occurrences of a specified character string pattern with a replacement string in the input file. Renders output to images.
def replace_to_images(self, input_file_name: str, save_options: aspose.words.saving.ImageSaveOptions, pattern: str, replacement: str):
...
| Parameter | Type | Description |
|---|---|---|
| input_file_name | str | The input file name. |
| save_options | ImageSaveOptions | The save options. |
| pattern | str | A string to be replaced. |
| replacement | str | A string to replace all occurrences of pattern. |
replace_to_images(input_file_name, save_options, pattern, replacement, options)
Replaces all occurrences of a specified character string pattern with a replacement string in the input file. Renders output to images.
def replace_to_images(self, input_file_name: str, save_options: aspose.words.saving.ImageSaveOptions, pattern: str, replacement: str, options: aspose.words.replacing.FindReplaceOptions):
...
| Parameter | Type | Description |
|---|---|---|
| input_file_name | str | The input file name. |
| save_options | ImageSaveOptions | The save options. |
| pattern | str | A string to be replaced. |
| replacement | str | A string to replace all occurrences of pattern. |
| options | FindReplaceOptions | FindReplaceOptions object to specify additional options. |
replace_to_images(input_stream, save_options, pattern, replacement)
Replaces all occurrences of a specified character string pattern with a replacement string in the input file. Renders output to images.
def replace_to_images(self, input_stream: io.BytesIO, save_options: aspose.words.saving.ImageSaveOptions, pattern: str, replacement: str):
...
| Parameter | Type | Description |
|---|---|---|
| input_stream | io.BytesIO | The input file stream. |
| save_options | ImageSaveOptions | The save options. |
| pattern | str | A string to be replaced. |
| replacement | str | A string to replace all occurrences of pattern. |
replace_to_images(input_stream, save_options, pattern, replacement, options)
Replaces all occurrences of a specified character string pattern with a replacement string in the input file. Renders output to images.
def replace_to_images(self, input_stream: io.BytesIO, save_options: aspose.words.saving.ImageSaveOptions, pattern: str, replacement: str, options: aspose.words.replacing.FindReplaceOptions):
...
| Parameter | Type | Description |
|---|---|---|
| input_stream | io.BytesIO | The input file stream. |
| save_options | ImageSaveOptions | The save options. |
| pattern | str | A string to be replaced. |
| replacement | str | 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:
doc = MY_DIR + 'Footer.docx'
pattern = '(C)2006 Aspose Pty Ltd.'
replacement = 'Copyright (C) 2024 by Aspose Pty Ltd.'
images = aw.lowcode.Replacer.replace_to_images(input_file_name=doc, save_options=aw.saving.ImageSaveOptions(aw.SaveFormat.PNG), pattern=pattern, replacement=replacement)
options = aw.replacing.FindReplaceOptions()
options.find_whole_words_only = False
images = aw.lowcode.Replacer.replace_to_images(input_file_name=doc, save_options=aw.saving.ImageSaveOptions(aw.SaveFormat.PNG), pattern=pattern, replacement=replacement, options=options)
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:
pattern = '(C)2006 Aspose Pty Ltd.'
replacement = 'Copyright (C) 2024 by Aspose Pty Ltd.'
with system_helper.io.FileStream(MY_DIR + 'Footer.docx', system_helper.io.FileMode.OPEN, system_helper.io.FileAccess.READ) as stream_in:
images = aw.lowcode.Replacer.replace_to_images(input_stream=stream_in, save_options=aw.saving.ImageSaveOptions(aw.SaveFormat.PNG), pattern=pattern, replacement=replacement)
options = aw.replacing.FindReplaceOptions()
options.find_whole_words_only = False
images = aw.lowcode.Replacer.replace_to_images(input_stream=stream_in, save_options=aw.saving.ImageSaveOptions(aw.SaveFormat.PNG), pattern=pattern, replacement=replacement, options=options)
See Also
- module aspose.words.lowcode
- class Replacer