Easily Perform Text Search and Highlighting
Aspose.Slides for PHP via Java 24.6 offers the new ITextSearchOptions
interface to search for text within presentations, slides, or text frames. Here’s how you can utilize the ITextSearchOptions
interface in your PHP apps:
$presentation = new Presentation("pres.pptx");
$textSearchOptions = new TextSearchOptions();
$textSearchOptions->setWholeWordsOnly(true);
$presentation->replaceText("the", "***", $textSearchOptions, null);
$presentation->save("pres-out.pptx", SaveFormat::Pptx);
$presentation->dispose();
Source*
This PHP presentations API release allows you to highlight specific text occurrences or utilize regular expressions for advanced highlighting options. The following code example demonstrates how to highlight text in your PowerPoint presentations:
$presentation = new Presentation("pres.pptx");
$textSearchOptions = new TextSearchOptions();
$textSearchOptions->setWholeWordsOnly(true);
$color = new Java("java.awt.Color");
# highlighting all separate 'the' occurrences
$presentation->highlightText("the", $color->MAGENTA, $textSearchOptions, null);
# highlight all 'abi' character sequences
$presentation->highlightText("abi", $color->RED);
$presentation->save("pres-out.pptx", SaveFormat::Pptx);
$presentation->dispose();
Source*
Similarly, you can check out the following PHP code sample to learn how to highlight text in your presentations using regular expressions:
$presentation = new Presentation("pres.pptx");
$regex = Pattern::compile("\\b[^\\s]{10,}\\b");
# highlighting all words with 10 symbols or longer
$color = new Java("java.awt.Color");
$presentation->highlightRegex($regex, $color->BLUE, null);
$presentation->save("pres-out.pptx", SaveFormat::Pptx);
$presentation->dispose();
Source*
Simplified Text Replacement
Effortlessly replace specific text using the newly introduced IPresentation.ReplaceText()
and IPresentation.ReplaceRegex()
methods in this Python API version. You can replace text in your presentations with specified text using the following PHP code example:
$presentation = new Presentation("pres.pptx");
$textSearchOptions = new TextSearchOptions();
$textSearchOptions->setWholeWordsOnly(true);
# Replace all separate 'the' occurrences with '***'
$presentation->replaceText("the", "***", $textSearchOptions, null);
$presentation->save("SomePresentation-out2.pptx", SaveFormat::Pptx);
$presentation->dispose();
Source*
Control Gradient Rendering
Aspose.Slides for Java 24.6 introduces the ISaveOption.GradientStyle
property, which enables you to customize the rendering style of two-color gradients while exporting presentations to images. This code sample showcases the feature usage:
$pres = new Presentation("pres.pptx");
$options = new RenderingOptions();
$options->setGradientStyle(GradientStyle::PowerPointUI);
$img = $pres->getSlides()->get_Item(0)->getImage($options, 2, 2);
$pres->dispose();
Source*
Deprecated API Members
Please note that this version has marked several methods and interfaces related to text highlighting as obsolete. They are scheduled for removal in version 24.10. These include:
- ITextFrame.highlightText()
- ITextFrame.highlightRegex()
- TextFrame.highlightText()
- TextFrame.highlightRegex()
- ITextHighlightingOptions
- TextHighlightingOptions
You can view the list of all new features, enhancements, and bug fixes introduced in this release by visiting Aspose.Slides for PHP via Java 24.6 Release Notes.