NodeRendererBaseSave Method (Stream, ImageSaveOptions)

Renders the shape into an image and saves into a stream.

Namespace:  Aspose.Words.Rendering
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public void Save(
	Stream stream,
	ImageSaveOptions saveOptions
)

Parameters

stream
Type: System.IOStream
The stream where to save the image of the shape.
saveOptions
Type: Aspose.Words.SavingImageSaveOptions
Specifies the options that control how the shape is rendered and saved. Can be null. If this is null, the image will be saved in the PNG format.
Examples
Shows how to export shapes to files in the local file system using a shape renderer.
// Open a document that contains shapes and get its shape collection
Document doc = new Document(MyDir + "Various shapes.docx");
List<Shape> shapes = doc.GetChildNodes(NodeType.Shape, true).Cast<Shape>().ToList();
Assert.AreEqual(7, shapes.Count);

// There are 7 shapes in the document, with one group shape with 2 child shapes
// The child shapes will be rendered but their parent group shape will be skipped, so we will see 6 output files
foreach (Shape shape in doc.GetChildNodes(NodeType.Shape, true).OfType<Shape>())
{
    ShapeRenderer renderer = shape.GetShapeRenderer();
    ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Png);
    renderer.Save(ArtifactsDir + $"Shape.RenderAllShapes.{shape.Name}.png", options);
}
See Also