ITextFrame
All Implemented Interfaces: com.aspose.slides.ISlideComponent
public interface ITextFrame extends ISlideComponent
Represents a TextFrame.
Methods
Method | Description |
---|---|
getParagraphs() | Returns the list of all paragraphs in a frame. |
getText() | Gets or sets the plain text for a TextFrame. |
setText(String value) | Gets or sets the plain text for a TextFrame. |
getTextFrameFormat() | Returns the formatting object for this TextFrame object. |
getHyperlinkQueries() | Provides easy access to contained hyperlinks. |
joinPortionsWithSameFormatting() | Joins runs with same formatting in all paragraphs. |
highlightText(String text, Color highlightColor) | Highlight all matches of sample in text frame text using specified color. |
highlightText(String text, Color highlightColor, ITextHighlightingOptions options) | Highlight all matches of sample in text frame text using specified color. |
highlightText(String text, Color highlightColor, ITextSearchOptions options, IFindResultCallback callback) | Highlight all matches of sample in text frame text using specified color. |
highlightRegex(Pattern regex, Color highlightColor, IFindResultCallback callback) | Highlight all matches of regular expression in text frame text using specified color. |
highlightRegex(String regex, Color highlightColor, ITextHighlightingOptions options) | Highlight all matches of regular expression in text frame text using specified color. |
replaceText(String oldText, String newText, ITextSearchOptions options, IFindResultCallback callback) | Replaces all occurrences of the specified text with another specified text. |
replaceRegex(Pattern regex, String newText, IFindResultCallback callback) | Replaces all matches of regular expression with specified string. |
getParagraphs()
public abstract IParagraphCollection getParagraphs()
Returns the list of all paragraphs in a frame. Read-only IParagraphCollection.
Returns: IParagraphCollection
getText()
public abstract String getText()
Gets or sets the plain text for a TextFrame. Read/write String.
Value: The text.
Returns: java.lang.String
setText(String value)
public abstract void setText(String value)
Gets or sets the plain text for a TextFrame. Read/write String.
Value: The text.
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String |
getTextFrameFormat()
public abstract ITextFrameFormat getTextFrameFormat()
Returns the formatting object for this TextFrame object. Read-only ITextFrameFormat.
Returns: ITextFrameFormat
getHyperlinkQueries()
public abstract IHyperlinkQueries getHyperlinkQueries()
Provides easy access to contained hyperlinks. Read-only IHyperlinkQueries.
Returns: IHyperlinkQueries
joinPortionsWithSameFormatting()
public abstract void joinPortionsWithSameFormatting()
Joins runs with same formatting in all paragraphs.
highlightText(String text, Color highlightColor)
public abstract void highlightText(String text, Color highlightColor)
Highlight all matches of sample in text frame text using specified color.
Parameters:
Parameter | Type | Description |
---|---|---|
text | java.lang.String | Text sample to highlight. |
highlightColor | java.awt.Color | Highlighting color. |
highlightText(String text, Color highlightColor, ITextHighlightingOptions options)
public abstract void highlightText(String text, Color highlightColor, ITextHighlightingOptions options)
Highlight all matches of sample in text frame text using specified color.
Parameters:
Parameter | Type | Description |
---|---|---|
text | java.lang.String | Text sample to highlight. |
highlightColor | java.awt.Color | Highlighting color. |
options | ITextHighlightingOptions | Highlighting options. |
highlightText(String text, Color highlightColor, ITextSearchOptions options, IFindResultCallback callback)
public abstract void highlightText(String text, Color highlightColor, ITextSearchOptions options, IFindResultCallback callback)
Highlight all matches of sample in text frame text using specified color.
The following sample code shows how to Highlight Text in a TextFrame. Presentation presentation = new Presentation("SomePresentation.pptx"); try { TextSearchOptions textSearchOptions = new TextSearchOptions(); textSearchOptions.setWholeWordsOnly(true); // highlighting all words 'important' ((AutoShape)presentation.getSlides().get_Item(0).getShapes().get_Item(0)).getTextFrame().highlightText("important", Color.BLUE); // highlighting all separate 'the' occurrences ((AutoShape)presentation.getSlides().get_Item(0).getShapes().get_Item(0)).getTextFrame().highlightText("the", Color.MAGENTA, textSearchOptions, null); presentation.save("SomePresentation-out2.pptx", SaveFormat.Pptx); } finally { if (presentation != null) presentation.dispose(); }
Parameters:
Parameter | Type | Description |
---|---|---|
text | java.lang.String | Text sample to highlight. |
highlightColor | java.awt.Color | Highlighting color. |
options | ITextSearchOptions | Text search options ITextSearchOptions. |
callback | IFindResultCallback | Callback object for saving replacement operation result IFindResultCallback. |
highlightRegex(Pattern regex, Color highlightColor, IFindResultCallback callback)
public abstract void highlightRegex(Pattern regex, Color highlightColor, IFindResultCallback callback)
Highlight all matches of regular expression in text frame text using specified color.
The following sample code shows how to Highlight Text using regular expression in a TextFrame. Presentation presentation = new Presentation("SomePresentation.pptx"); try { Pattern regex = Pattern.compile("\\b[^\\s]{5,}\\b"); // highlighting all words with 5 symbols or longer ((AutoShape)presentation.getSlides().get_Item(0).getShapes().get_Item(0)).getTextFrame().highlightRegex(regex, Color.BLUE, null); presentation.save("SomePresentation-out.pptx", SaveFormat.Pptx); } finally { if (presentation != null) presentation.dispose(); }
Parameters:
Parameter | Type | Description |
---|---|---|
regex | java.util.regex.Pattern | The regular expression java.util.regex.Pattern to get strings to be replaced. |
highlightColor | java.awt.Color | Highlighting color. |
callback | IFindResultCallback | Callback object for saving replacement operation result IFindResultCallback. |
highlightRegex(String regex, Color highlightColor, ITextHighlightingOptions options)
public abstract void highlightRegex(String regex, Color highlightColor, ITextHighlightingOptions options)
Highlight all matches of regular expression in text frame text using specified color.
Parameters:
Parameter | Type | Description |
---|---|---|
regex | java.lang.String | Text of regular expression to get text to highlight. |
highlightColor | java.awt.Color | Highlighting color. |
options | ITextHighlightingOptions | Highlighting options. |
replaceText(String oldText, String newText, ITextSearchOptions options, IFindResultCallback callback)
public abstract void replaceText(String oldText, String newText, ITextSearchOptions options, IFindResultCallback callback)
Replaces all occurrences of the specified text with another specified text.
The following sample code shows how to replace one speified string with another speified string. Presentation presentation = new Presentation("SomePresentation.pptx"); try { TextSearchOptions textSearchOptions = new TextSearchOptions(); textSearchOptions.setWholeWordsOnly(true); // Replace all separate 'the' occurrences with '***' ((AutoShape)presentation.getSlides().get_Item(0).getShapes().get_Item(0)).getTextFrame().replaceText("the", "***", textSearchOptions, null); presentation.save("SomePresentation-out2.pptx", SaveFormat.Pptx); } finally { if (presentation != null) presentation.dispose(); }
Parameters:
Parameter | Type | Description |
---|---|---|
oldText | java.lang.String | The string to be replaced. |
newText | java.lang.String | The string to replace all occurrences of oldText. |
options | ITextSearchOptions | Text search options ITextSearchOptions. |
callback | IFindResultCallback | Callback object for saving replacement operation result IFindResultCallback. |
replaceRegex(Pattern regex, String newText, IFindResultCallback callback)
public abstract void replaceRegex(Pattern regex, String newText, IFindResultCallback callback)
Replaces all matches of regular expression with specified string.
The following sample code shows how to replace text using regular expression with specified string. Presentation presentation = new Presentation("SomePresentation.pptx"); try { Pattern regex = Pattern.compile("\\b[^\\s]{5,}\\b"); // Replace all words with 5 symbols or longer with '***' ((AutoShape)presentation.getSlides().get_Item(0).getShapes().get_Item(0)).getTextFrame().replaceRegex(regex, "***", null); presentation.save("SomePresentation-out.pptx", SaveFormat.Pptx); } finally { if (presentation != null) presentation.dispose(); }
Parameters:
Parameter | Type | Description |
---|---|---|
regex | java.util.regex.Pattern | The regular expression java.util.regex.Pattern to get strings to be replaced. |
newText | java.lang.String | The string to replace all occurrences of strings to be replaced. |
callback | IFindResultCallback | Callback object for saving replacement operation result IFindResultCallback. |