Convenient Text Search
Aspose.Slides for Python via Java 24.6 lets you leverage the new ITextSearchOptions
interface to precisely search for text within presentations, slides, or text frames. The following code example highlights how to use the newly added interface for performing text searches within your Python apps:
presentation = Presentation("pres.pptx");
textSearchOptions = TextSearchOptions();
textSearchOptions.setWholeWordsOnly(True);
presentation.replaceText("the", "***", textSearchOptions, None);
presentation.save("pres-out.pptx", SaveFormat.Pptx);
presentation.dispose();
Source*
Powerful Text Highlighting
Developers can employ the ITextFrame.HighlightText()
and ITextFrame.HighlightRegex()
methods in the latest Python presentations library to visually distinguish specific text elements or patterns within presentations. Please check out this coding sample to learn how to highlight text:
presentation = Presentation("pres.pptx");
textFrame = presentation.getSlides().get_Item(0).getShapes().get_Item(0).getTextFrame();
# highlighting all words 'important'
textFrame.highlightText("important", Color.BLUE);
textSearchOptions = TextSearchOptions();
textSearchOptions.setWholeWordsOnly(True);
# highlighting all separate 'the' occurrences
textFrame.highlightText("the", Color.MAGENTA, textSearchOptions, None);
presentation.save("pres-out2.pptx", SaveFormat.Pptx);
presentation.dispose();
Source*
This code example shows how to use regex for text highlighting in a TextFrame:
presentation = Presentation("pres.pptx");
regex = Pattern.compile("\\b[^\\s]{10,}\\b");
# highlighting all words with 10 symbols or longer
presentation.getSlides().get_Item(0).getShapes().get_Item(0).getTextFrame().highlightRegex(regex, Color.BLUE, None);
presentation.save("SomePresentation-out.pptx", SaveFormat.Pptx);
presentation.dispose();
Source*
Flexible Text Replacement
The ITextFrame.ReplaceText()
and ITextFrame.ReplaceRegex()
methods in Aspose.Slides for Python via Java 24.6 allow users to substitute text with alternative content, supporting regular expressions and whole-word replacements. For instance, this code sample illustrates the text replacement functionality in Python, using regular expression:
presentation = Presentation("pres.pptx");
regex = Pattern.compile("\\b[^\\s]{5,}\\b");
# Replace all words with 5 symbols or longer with '***'
presentation.getSlides().get_Item(0).getShapes().get_Item(0).getTextFrame().replaceRegex(regex, "***", None);
presentation.save("SomePresentation-out.pptx", SaveFormat.Pptx);
presentation.dispose();
Source*
Enhanced Gradient Rendering
With the newest Python presentation processing API, you can enjoy better control over the visual appearance of two-color gradients in exported presentations using the newly introduced ISaveOption.GradientStyle
property. This code sample demonstrates the feature usage:
pres = Presentation("pres.pptx");
options = RenderingOptions();
options.setGradientStyle(GradientStyle.PowerPointUI);
img = pres.getSlides().get_Item(0).getImage(options, 2, 2);
pres.dispose();
Source*
Deprecated Methods and Interfaces
The following methods and interfaces are marked as obsolete in this Python library release and will be removed in version 24.10:
Methods:
- ITextFrame.highlightText(string text, Color highlightColor, ITextHighlightingOptions options)
- ITextFrame.highlightRegex(string regex, Color highlightColor, ITextHighlightingOptions options)
- TextFrame.highlightText(string text, Color highlightColor, ITextHighlightingOptions options)
- TextFrame.highlightRegex(string regex, Color highlightColor, ITextHighlightingOptions options)
Interfaces and Classes:
- ITextHighlightingOptions
- TextHighlightingOptions
You can view the list of all new features, enhancements, and bug fixes introduced in this release by visiting Aspose.Slides for Python via Java 24.6 Release Notes.