TextFrame

Inheritance: java.lang.Object

All Implemented Interfaces: com.aspose.slides.ITextFrame, com.aspose.slides.IDOMObject

public final class TextFrame implements ITextFrame, IDOMObject

Represents a TextFrame.

Methods

MethodDescription
getParent_Immediate()
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, Integer highlightColor)Highlights all matches of the sample text with the specified color.
highlightText(String text, Integer highlightColor, ITextHighlightingOptions options)Highlights all matches of the sample text with the specified color.
highlightText(String text, Integer highlightColor, ITextSearchOptions options, IFindResultCallback callback)Highlights all matches of the sample text with the specified color.
highlightRegex(String regex, Integer highlightColor, ITextHighlightingOptions options)Highlights all matches of the regular expression with the specified color.
highlightRegex(Pattern regex, Integer highlightColor, IFindResultCallback callback)Highlights all matches of the regular expression with the 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.
getSlide()Returns the parent slide of a TextFrame.
getPresentation()Returns the parent presentation of a TextFrame.

getParent_Immediate()

public final IDOMObject getParent_Immediate()

Returns Parent_Immediate object. Read-only IDOMObject.

Returns: com.aspose.slides.IDOMObject

getParagraphs()

public final IParagraphCollection getParagraphs()

Returns the list of all paragraphs in a frame. Read-only IParagraphCollection.

Returns: IParagraphCollection

getText()

public final 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 final void setText(String value)

Gets or sets the plain text for a TextFrame. Read/write String.

Value: The text.

Parameters:

ParameterTypeDescription
valuejava.lang.String

getTextFrameFormat()

public final ITextFrameFormat getTextFrameFormat()

Returns the formatting object for this TextFrame object. Read-only ITextFrameFormat.

Returns: ITextFrameFormat

getHyperlinkQueries()

public final IHyperlinkQueries getHyperlinkQueries()

Provides easy access to contained hyperlinks. Read-only IHyperlinkQueries.

Returns: IHyperlinkQueries

joinPortionsWithSameFormatting()

public final void joinPortionsWithSameFormatting()

Joins runs with same formatting in all paragraphs.

highlightText(String text, Integer highlightColor)

public final void highlightText(String text, Integer highlightColor)

Highlights all matches of the sample text with the specified color.

Parameters:

ParameterTypeDescription
textjava.lang.StringText sample to highlight.
highlightColorjava.lang.IntegerThe color to highlight the text.

highlightText(String text, Integer highlightColor, ITextHighlightingOptions options)

public final void highlightText(String text, Integer 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();
 }

Parameters:

ParameterTypeDescription
textjava.lang.StringThe text to highlight.
highlightColorjava.lang.IntegerThe color to highlight the text.
optionsITextHighlightingOptionsHighlighting options.

highlightText(String text, Integer highlightColor, ITextSearchOptions options, IFindResultCallback callback)

public final void highlightText(String text, Integer 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();
 }

Parameters:

ParameterTypeDescription
textjava.lang.StringThe text to highlight.
highlightColorjava.lang.IntegerThe color to highlight the text.
optionsITextSearchOptionsText search options ITextSearchOptions.
callbackIFindResultCallbackThe callback object for receiving search results IFindResultCallback.

highlightRegex(String regex, Integer highlightColor, ITextHighlightingOptions options)

public final void highlightRegex(String regex, Integer 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();
 }

Parameters:

ParameterTypeDescription
regexjava.lang.StringText of regular expression to get text to highlight.
highlightColorjava.lang.IntegerThe color to highlight the text.
optionsITextHighlightingOptionsHighlighting options.

highlightRegex(Pattern regex, Integer highlightColor, IFindResultCallback callback)

public final void highlightRegex(Pattern regex, Integer 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();
 }

Parameters:

ParameterTypeDescription
regexjava.util.regex.PatternThe regular expression java.util.regex.Pattern to get strings to highlight.
highlightColorjava.lang.IntegerThe color to highlight the text.
callbackIFindResultCallbackThe callback object for receiving search results IFindResultCallback.

replaceText(String oldText, String newText, ITextSearchOptions options, IFindResultCallback callback)

public final 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:

ParameterTypeDescription
oldTextjava.lang.StringThe string to be replaced.
newTextjava.lang.StringThe string to replace all occurrences of oldText.
optionsITextSearchOptionsText search options ITextSearchOptions.
callbackIFindResultCallbackCallback object for saving replacement operation result IFindResultCallback.

replaceRegex(Pattern regex, String newText, IFindResultCallback callback)

public final 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:

ParameterTypeDescription
regexjava.util.regex.PatternThe regular expression java.util.regex.Pattern to get strings to be replaced.
newTextjava.lang.StringThe string to replace all occurrences of strings to be replaced.
callbackIFindResultCallbackCallback object for saving replacement operation result IFindResultCallback.

getSlide()

public final IBaseSlide getSlide()

Returns the parent slide of a TextFrame. Read-only IBaseSlide.

Returns: IBaseSlide

getPresentation()

public final IPresentation getPresentation()

Returns the parent presentation of a TextFrame. Read-only IPresentation.

Returns: IPresentation