GetImage
Contents
[
Hide
]GetImage()
Returns an image of the paragraph.
public IImage GetImage()
Return Value
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.
Examples
The following example shows how to render a paragraph as an image:
using (Presentation pres = new Presentation())
{
IAutoShape shape = pres.Slides[0].Shapes.AddAutoShape(
ShapeType.Rectangle, 50, 50, 150, 50);
IParagraph paragraph = shape.TextFrame.Paragraphs[0];
paragraph.Text = "Aspose Paragraph GetImage() Example";
using (IImage paragraphImage = paragraph.GetImage())
{
paragraphImage.Save("paragraph.png");
}
}
See Also
- interface IImage
- class Paragraph
- namespace Aspose.Slides
- assembly Aspose.Slides
GetImage(float, float)
Returns an image of the paragraph with the specified scale.
public IImage GetImage(float scaleX, float scaleY)
| Parameter | Type | Description |
|---|---|---|
| scaleX | Single | The horizontal scale factor applied to the paragraph image. |
| scaleY | Single | The vertical scale factor applied to the paragraph image. |
Return Value
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.
Examples
The following example shows how to render each text box paragraph on a slide as an image with custom scaling:
using (Presentation pres = new Presentation("sample.pptx"))
{
ISlide slide = pres.Slides[0];
int shapeIndex = 0;
foreach (IShape shape in slide.Shapes)
{
shapeIndex++;
IAutoShape autoShape = shape as IAutoShape;
if (autoShape == null)
continue;
int paragraphIndex = 0;
foreach (IParagraph paragraph in autoShape.TextFrame.Paragraphs)
{
paragraphIndex++;
using (IImage paragraphImage = paragraph.GetImage(2f, 2f))
{
paragraphImage?.Save(string.Format("shape{0}_paragraph{1}.png", shapeIndex, paragraphIndex));
}
}
}
}
See Also
- interface IImage
- class Paragraph
- namespace Aspose.Slides
- assembly Aspose.Slides