public interface ITextFrame extends ISlideComponent
Represents a TextFrame.
| Modifier and Type | Method and Description |
|---|---|
IHyperlinkQueries |
getHyperlinkQueries()
Provides easy access to contained hyperlinks.
|
IParagraphCollection |
getParagraphs()
Returns the list of all paragraphs in a frame.
|
ICell |
getParentCell()
Returns the parent cell or null if the parent object does not implement the ICell interface.
|
IShape |
getParentShape()
Returns the parent shape or null if the parent object does not implement the IShape interface
Read-only
IShape. |
java.lang.String |
getText()
Gets or sets the plain text for a TextFrame.
|
ITextFrameFormat |
getTextFrameFormat()
Returns the formatting object for this TextFrame object.
|
void |
highlightRegex(java.util.regex.Pattern regex,
java.awt.Color highlightColor,
IFindResultCallback callback)
Highlights all matches of the regular expression with the specified color.
|
void |
highlightRegex(java.lang.String regex,
java.awt.Color highlightColor,
ITextHighlightingOptions options)
Deprecated.
Use HighlightRegex(Regex regex, Color highlightColor, IFindResultCallback callback) method instead. The method will be removed after release of version 24.10.
|
void |
highlightText(java.lang.String text,
java.awt.Color highlightColor)
Highlights all matches of the sample text with the specified color.
|
void |
highlightText(java.lang.String text,
java.awt.Color highlightColor,
ITextHighlightingOptions options)
Deprecated.
Use HighlightText(string text, Color highlightColor, ITextSearchOptions options, IFindResultCallback callback) method instead. The method will be removed after release of version 24.10.
|
void |
highlightText(java.lang.String text,
java.awt.Color highlightColor,
ITextSearchOptions options,
IFindResultCallback callback)
Highlights all matches of the sample text with the specified color.
|
void |
joinPortionsWithSameFormatting()
Joins runs with same formatting in all paragraphs.
|
void |
replaceRegex(java.util.regex.Pattern regex,
java.lang.String newText,
IFindResultCallback callback)
Replaces all matches of the regular expression with the specified string.
|
void |
replaceText(java.lang.String oldText,
java.lang.String newText,
ITextSearchOptions options,
IFindResultCallback callback)
Replaces all occurrences of the specified text with another specified text.
|
void |
setText(java.lang.String value)
Gets or sets the plain text for a TextFrame.
|
java.lang.String[] |
splitTextByColumns()
Splits the text content of the
ITextFrame into an array of strings,
where each element corresponds to a separate text column within the frame. |
getSlidegetPresentationIParagraphCollection getParagraphs()
Returns the list of all paragraphs in a frame.
Read-only IParagraphCollection.
java.lang.String getText()
Gets or sets the plain text for a TextFrame.
Read/write String.
void setText(java.lang.String value)
Gets or sets the plain text for a TextFrame.
Read/write String.
ITextFrameFormat getTextFrameFormat()
Returns the formatting object for this TextFrame object.
Read-only ITextFrameFormat.
IHyperlinkQueries getHyperlinkQueries()
Provides easy access to contained hyperlinks.
Read-only IHyperlinkQueries.
IShape getParentShape()
Returns the parent shape or null if the parent object does not implement the IShape interface
Read-only IShape.
The following code sample showsPresentation presentation = new Presentation("SomePresentation.pptx"); try { AutoShape autoShape = (AutoShape)presentation.getSlides().get_Item(0).getShapes().get_Item(0); Table table = (Table)presentation.getSlides().get_Item(0).getShapes().get_Item(1); // These assertions are always true Assert.assertTrue(autoShape.getTextFrame().getParentShape() == autoShape); Assert.assertTrue((table.get_Item(0,0).getTextFrame()).getParentShape() == null); } finally { if (presentation != null) presentation.dispose(); }
ICell getParentCell()
Returns the parent cell or null if the parent object does not implement the ICell interface.
Read-only ICell.
The following code sample showsPresentation presentation = new Presentation("SomePresentation.pptx"); try { AutoShape autoShape = (AutoShape)presentation.getSlides().get_Item(0).getShapes().get_Item(0); Table table = (Table)presentation.getSlides().get_Item(0).getShapes().get_Item(1); // These assertions are always true Assert.assertTrue(table.get_Item(0,0).getTextFrame().getParentCell() == table.get_Item(0,0)); Assert.assertTrue(autoShape.getTextFrame().getParentCell() == null); } finally { if (presentation != null) presentation.dispose(); }
void joinPortionsWithSameFormatting()
Joins runs with same formatting in all paragraphs.
void highlightText(java.lang.String text,
java.awt.Color highlightColor)
Highlights all matches of the sample text with the specified color.
text - The text to highlight.highlightColor - The color to highlight the text.java.lang.String[] splitTextByColumns()
Splits the text content of the ITextFrame into an array of strings,
where each element corresponds to a separate text column within the frame.
The following example demonstrates how to usesplitTextByColumns():Presentation pres = new Presentation("example.pptx"); try { // Get the first shape on the slide and cast it to ITextFrame ITextFrame textFrame = (ITextFrame) pres.getSlides().get_Item(0).getShapes().get_Item(0); // Split the text frame content into columns String[] columnsText = textFrame.splitTextByColumns(); // Print each column's text to the console for (String column : columnsText) System.out.println(column); } finally { if (pres != null) pres.dispose(); }
ITextFrame.
@Deprecated
void highlightText(java.lang.String text,
java.awt.Color highlightColor,
ITextHighlightingOptions options)
Highlights all matches of the sample text with the specified color.
text - The text to highlight.highlightColor - The color to highlight the text.options - Highlighting options.void highlightText(java.lang.String text,
java.awt.Color highlightColor,
ITextSearchOptions options,
IFindResultCallback callback)
Highlights all matches of the sample text with the specified color.
The following code sample 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(); }
text - The text to highlight.highlightColor - The color to highlight the text.options - Text search options ITextSearchOptions.callback - The callback object for receiving search results IFindResultCallback.void highlightRegex(java.util.regex.Pattern regex,
java.awt.Color highlightColor,
IFindResultCallback callback)
Highlights all matches of the regular expression with the specified color.
The following code sample shows how to highlight text in a TextFrame using a regular expression.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(); }
regex - The regular expression Pattern to get strings to highlight.highlightColor - The color to highlight the text.callback - The callback object for receiving search results IFindResultCallback.@Deprecated
void highlightRegex(java.lang.String regex,
java.awt.Color highlightColor,
ITextHighlightingOptions options)
Highlights all matches of the regular expression with the specified color.
regex - Text of regular expression to get text to highlight.highlightColor - The color to highlight the text.options - Highlighting options.void replaceText(java.lang.String oldText,
java.lang.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 specified string with another specified 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(); }
oldText - The string to be replaced.newText - The string to replace all occurrences of oldText.options - Text search options ITextSearchOptions.callback - The callback object for receiving search results IFindResultCallback.void replaceRegex(java.util.regex.Pattern regex,
java.lang.String newText,
IFindResultCallback callback)
Replaces all matches of the regular expression with the specified string.
The following code sample shows how to replace text using regular expression with the 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(); }
regex - The regular expression Pattern to get strings to replace.newText - The string to replace all occurrences of the strings to be replaced.callback - The callback object for receiving search results IFindResultCallback.Copyright © 2004-2025 Aspose Pty Ltd. All Rights Reserved.