public final class TextFrame extends java.lang.Object implements ITextFrame
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.
|
com.aspose.slides.IDOMObject |
getParent_Immediate()
Returns Parent_Immediate object.
|
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. |
IPresentation |
getPresentation()
Returns the parent presentation of a TextFrame.
|
IBaseSlide |
getSlide()
Returns the parent slide of a TextFrame.
|
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) 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 regular expression with 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. |
public final com.aspose.slides.IDOMObject getParent_Immediate()
Returns Parent_Immediate object.
Read-only IDOMObject.
public final IParagraphCollection getParagraphs()
Returns the list of all paragraphs in a frame.
Read-only IParagraphCollection.
getParagraphs in interface ITextFramepublic final java.lang.String getText()
Gets or sets the plain text for a TextFrame.
Read/write String.
getText in interface ITextFramepublic final void setText(java.lang.String value)
Gets or sets the plain text for a TextFrame.
Read/write String.
setText in interface ITextFramepublic final ITextFrameFormat getTextFrameFormat()
Returns the formatting object for this TextFrame object.
Read-only ITextFrameFormat.
getTextFrameFormat in interface ITextFramepublic final IHyperlinkQueries getHyperlinkQueries()
Provides easy access to contained hyperlinks.
Read-only IHyperlinkQueries.
getHyperlinkQueries in interface ITextFramepublic final void joinPortionsWithSameFormatting()
Joins runs with same formatting in all paragraphs.
joinPortionsWithSameFormatting in interface ITextFramepublic final void highlightText(java.lang.String text,
java.awt.Color highlightColor)
Highlights all matches of the sample text with the specified color.
highlightText in interface ITextFrametext - Text sample to highlight.highlightColor - The color to highlight the text.@Deprecated
public final void highlightText(java.lang.String text,
java.awt.Color highlightColor,
ITextHighlightingOptions options)
Highlights all matches of the sample text with the specified color.
The following sample code shows how to Highlight Text in a TextFrame.try { TextHighlightingOptions textHighlightingOptions = new TextHighlightingOptions(); textHighlightingOptions.setWholeWordsOnly(true); // highlighting all words 'important' ((AutoShape)pres.getSlides().get_Item(0).getShapes().get_Item(0)).getTextFrame().highlightText("title", Color.BLUE); // highlighting all separate 'the' occurrences ((AutoShape)pres.getSlides().get_Item(0).getShapes().get_Item(0)).getTextFrame().highlightText("to", Color.MAGENTA, textHighlightingOptions); pres.save("SomePresentation-out2.pptx", SaveFormat.Pptx); } finally { if (pres != null) pres.dispose(); }
highlightText in interface ITextFrametext - The text to highlight.highlightColor - The color to highlight the text.options - Highlighting options.public final 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(); }
splitTextByColumns in interface ITextFrameITextFrame.
public final 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(); }
highlightText in interface ITextFrametext - 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.@Deprecated
public final void highlightRegex(java.lang.String regex,
java.awt.Color highlightColor,
ITextHighlightingOptions options)
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 pres = new Presentation("SomePresentation.pptx"); try { TextHighlightingOptions options = new TextHighlightingOptions(); // highlighting all words with 10 symbols or longer ((AutoShape) pres.getSlides().get_Item(0).getShapes().get_Item(0)).getTextFrame().highlightRegex("\\b[^\\s){5,}\\b", Color.BLUE, options); pres.save("SomePresentation-out.pptx", SaveFormat.Pptx); } finally { if (pres != null) pres.dispose(); }
highlightRegex in interface ITextFrameregex - Text of regular expression to get text to highlight.highlightColor - The color to highlight the text.options - Highlighting options.public final 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(); }
highlightRegex in interface ITextFrameregex - 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.public final 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 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(); }
replaceText in interface ITextFrameoldText - The string to be replaced.newText - The string to replace all occurrences of oldText.options - Text search options ITextSearchOptions.callback - Callback object for saving replacement operation result IFindResultCallback.public final void replaceRegex(java.util.regex.Pattern regex,
java.lang.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(); }
replaceRegex in interface ITextFrameregex - The regular expression Pattern to get strings to be replaced.newText - The string to replace all occurrences of strings to be replaced.callback - Callback object for saving replacement operation result IFindResultCallback.public final IBaseSlide getSlide()
Returns the parent slide of a TextFrame.
Read-only IBaseSlide.
getSlide in interface ISlideComponentpublic final IPresentation getPresentation()
Returns the parent presentation of a TextFrame.
Read-only IPresentation.
getPresentation in interface IPresentationComponentpublic final 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(); }
getParentShape in interface ITextFramepublic final 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(); }
getParentCell in interface ITextFrameCopyright © 2004-2025 Aspose Pty Ltd. All Rights Reserved.