IParagraph
All Implemented Interfaces: com.aspose.slides.ISlideComponent
public interface IParagraph extends ISlideComponent
Represents a paragraph of a text.
Methods
| Method | Description |
|---|---|
| getPortions() | Returns the collection of a text portions. |
| getParagraphFormat() | Returns the formatting object for this paragraph. |
| joinPortionsWithSameFormatting() | Joins runs with same formatting. |
| getText() | Gets or sets the the plain text of a paragraph. |
| setText(String value) | Gets or sets the the plain text of a paragraph. |
| getRect() | Get coordinates of rect that bounds paragraph. |
| getLinesCount() | Get number of lines in a paragraph. |
| getImage() | Returns an image of the paragraph. |
| getImage(float scaleX, float scaleY) | Returns an image of the paragraph with the specified scale. |
| getEndParagraphPortionFormat() | Specifies the portion properties that are to be used if another portion is inserted after the last one. |
| setEndParagraphPortionFormat(IPortionFormat value) | Specifies the portion properties that are to be used if another portion is inserted after the last one. |
getPortions()
public abstract IPortionCollection getPortions()
Returns the collection of a text portions. Read-only IPortionCollection.
Returns: IPortionCollection
getParagraphFormat()
public abstract IParagraphFormat getParagraphFormat()
Returns the formatting object for this paragraph. Read-only IParagraphFormat.
Returns: IParagraphFormat
joinPortionsWithSameFormatting()
public abstract void joinPortionsWithSameFormatting()
Joins runs with same formatting.
getText()
public abstract String getText()
Gets or sets the the plain text of a paragraph. Read/write String.
Value: The text.
Returns: java.lang.String
setText(String value)
public abstract void setText(String value)
Gets or sets the the plain text of a paragraph. Read/write String.
Value: The text.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | java.lang.String |
getRect()
public abstract Rectangle2D.Float getRect()
Get coordinates of rect that bounds paragraph. The rect includes all the lines of text in paragraph, including empty ones.
Returns: java.awt.geom.Rectangle2D.Float - Rectangle that bounds paragraph java.awt.geom.Rectangle2D.Float
getLinesCount()
public abstract int getLinesCount()
Get number of lines in a paragraph.
Example: Presentation pres = new Presentation(); try { ISlide sld = pres.getSlides().get_Item(0); IAutoShape ashp = sld.getShapes().addAutoShape(ShapeType.Rectangle, 150, 75, 150, 50); IParagraph para = ashp.getTextFrame().getParagraphs().get_Item(0); IPortion portion = para.getPortions().get_Item(0); portion.setText("Aspose Paragraph GetLinesCount() Example"); System.out.println("Lines Count = " + para.getLinesCount()); } finally { if (pres != null) pres.dispose(); }
Returns: int - Lines count in a paragraph
getImage()
public abstract IImage getImage()
Returns an image of the paragraph.
The following example shows how to render a paragraph as an image: Presentation pres = new Presentation(); try { IAutoShape shape = pres.getSlides().get_Item(0).getShapes().addAutoShape( ShapeType.Rectangle, 50, 50, 150, 50); IParagraph paragraph = shape.getTextFrame().getParagraphs().get_Item(0); paragraph.setText("Aspose Paragraph GetImage() Example"); IImage paragraphImage = paragraph.getImage(); try { paragraphImage.save("paragraph.png"); } finally { if (paragraphImage != null) paragraphImage.dispose(); } } finally { if (pres != null) pres.dispose(); }
Returns: IImage - An image containing the rendered paragraph, or null if the paragraph cannot be found in its parent collection, has no valid rendering bounds, or an error occurs while rendering the image.
getImage(float scaleX, float scaleY)
public abstract IImage getImage(float scaleX, float scaleY)
Returns an image of the paragraph with the specified scale.
The following example shows how to render each text box paragraph on a slide as an image with custom scaling: Presentation pres = new Presentation("sample.pptx"); try { ISlide slide = pres.getSlides().get_Item(0); int shapeIndex = 0; for (IShape shape : slide.getShapes()) { shapeIndex++; if (shape instanceof IAutoShape) { IAutoShape autoShape = (IAutoShape)shape; int paragraphIndex = 0; for (IParagraph paragraph : autoShape.getTextFrame().getParagraphs()) { paragraphIndex++; IImage paragraphImage = paragraph.getImage(2f, 2f); try { if (paragraphImage != null) paragraphImage.save("shape"+shapeIndex+"_paragraph"+paragraphIndex+".png"); } finally { if (paragraphImage != null) paragraphImage.dispose(); } } } } } finally { if (pres != null) pres.dispose(); }
Parameters:
| Parameter | Type | Description |
|---|---|---|
| scaleX | float | The horizontal scale factor applied to the paragraph image. |
| scaleY | float | The vertical scale factor applied to the paragraph image. |
Returns: IImage - An image containing the rendered paragraph, or null if the paragraph cannot be found in its parent collection, has no valid rendering bounds, or an error occurs while rendering the image.
getEndParagraphPortionFormat()
public abstract IPortionFormat getEndParagraphPortionFormat()
Specifies the portion properties that are to be used if another portion is inserted after the last one.
Returns: IPortionFormat
setEndParagraphPortionFormat(IPortionFormat value)
public abstract void setEndParagraphPortionFormat(IPortionFormat value)
Specifies the portion properties that are to be used if another portion is inserted after the last one.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | IPortionFormat |