aspose.diagram
Class Shape

Contains elements that define a shape in a Master, Page, or group shape element.

Example:

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");

diagram = new aspose.diagram.Diagram("RetrieveShapeInfo.vsd");

for (it = diagram.getPages().getPage("Page-2").getShapes().iterator(); it.hasNext();) {
    shape = it.next();
    // Display information about the shapes
    console.log("Shape ID : " + shape.getID());
    console.log("Name : " + shape.getName());
    console.log("Master Shape : " + shape.getMaster().getName());
}

Constructor Summary
Shape()
           Constructor.
 
Property Getters/Setters Summary
functiongetActiveXControl()
           Gets the ActiveX control.
functiongetActs()
           Contains a collection of Act elements.
functiongetAlign()
           Indicates the alignment of a shape with respect to the guide or guide point to which the shape is glued. The Align element appears only for shapes that are glued to guides or guide points.
functiongetChars()
           Contains a collection of Char elements.
functiongetConnectionABCDs()
           Contains a collection of ConnectionABCD elements.
functiongetConnections()
           Contains a collection of Connection elements.
functiongetControlData()
           Gets the data of control.
functiongetControls()
           Contains a collection of Control elements.
functiongetData1()
functionsetData1(value)
           Contains an arbitrary string value that is used to supply additional information about a shape.
functiongetData2()
functionsetData2(value)
           Contains an arbitrary string value that is used to supply additional information about a shape.
functiongetData3()
functionsetData3(value)
           Contains an arbitrary string value that is used to supply additional information about a shape.
functiongetDel()
functionsetDel(value)
           A flag indicating whether the element is deleted locally. A value of 1 indicates that the element is deleted locally. The value of the property is BOOL integer constant.
functiongetDiagram()
functionsetDiagram(value)
           Root element of Visio objects hierarchy.
functiongetEvent()
functionsetEvent(value)
           Contains elements that specify formulas that control shape events.
functiongetFields()
           Contains a collection of Field elements.
functiongetFill()
           Contains the current fill formatting values for the shape and the shape's drop shadow, including pattern, foreground color, and background color.
functiongetFillStyle()
functionsetFillStyle(value)
           StyleSheet from which this shape inherits fill formatting.
functiongetForeign()
           Contains elements specifying the width and height of an object from another program used in a Microsoft Visio document. Also includes elements specifying the distance the object's image is offset within its borders.
functiongetForeignData()
           Contains a MIME (Multipurpose Internet Mail Extensions) encoded BLOB of picture data, such as Windows metafile, bitmap, or OLE data.
functiongetGeoms()
           Contains a collection of Geom elements.
functiongetGroup()
           Contains elements that control how you add shapes to a group, move members of a group, and select groups.
functiongetHelp()
           Contains elements specifying the Shape element's Help file topic and copyright information.
functiongetHyperlinks()
           Contains a collection of Hyperlink elements.
functiongetID()
functionsetID(value)
           The unique ID of the element within its parent element.
functiongetImage()
           Contains the gamma, brightness, contrast, blur, sharpen, denoise, and transparency values for a bitmap.
functiongetInheritChars()
           Contains the char values for the shape inherit by the master shape.
functiongetInheritFill()
           Contains the fill formatting values for the shape inherit by the parent style and the master shape.
functiongetInheritLine()
           Contains the line formatting values for the shape inherit by the parent style and the master shape.
functiongetInheritProps()
           Contains the props for the shape inherit by the master shape.
functiongetInheritUsers()
           Contains the users for the shape inherit by the master shape.
functionisTextEmpty()
           Indicate the shape has text and the text is empty or not.
functiongetLayerMem()
           Contains the LayerMember element, which specifies each layer to which the shape is assigned.
functiongetLayout()
           Contains elements that control shape placement and connector routing settings.
functiongetLine()
           Contains elements that control line attributes for a shape, such as pattern, weight, and color. These elements determine whether the line ends are formatted (for example, with an arrowhead), the size of line end formats, radius of the rounding circle applied to the line, and line cap style (round or square).
functiongetLineStyle()
functionsetLineStyle(value)
           StyleSheet from which this shape inherits line formatting
functiongetMaster()
functionsetMaster(value)
           The Master from which the shape inherits its data.
functiongetMasterShape()
functionsetMasterShape(value)
           This attribute may only be present in shapes that are members of a group shape, and the group is an instance of a master. The attribute contains an ID that references the corresponding sub-shape in the master.
functiongetMisc()
           Contains elements specifying the Shape element's Help file topic and copyright information.
functiongetName()
functionsetName(value)
           The name of the element.
functiongetNameU()
functionsetNameU(value)
           The universal name of the element.
functiongetOneD()
           Determines whether the shape behaves as a one-dimensional (1-D) object. Read-only.
functiongetPage()
functionsetPage(value)
           Root element of Visio objects hierarchy.
functiongetParas()
           Contains a collection of Para elements.
functiongetParentShape()
functionsetParentShape(value)
           Shape's parent.
functiongetProps()
functionsetProps(value)
           Contains a collection of Prop elements.
functiongetProtection()
           Locking helps prevent inadvertent changes to the shape but does not prevent Microsoft Visio from resetting values in other circumstances. It also does not protect against changes made in the ShapeSheet window.
functiongetScratchs()
           Contains a collection of Scratch elements.
functiongetShapes()
           Contains a collection of Shape elements.
functiongetSmartTagDefs()
           Contains a collection of SmartTagDef elements.
functiongetTabsCollection()
           Contains a collection of Tab elements.
functiongetText()
functionsetText(value)
           Contains the text of a shape.
functiongetTextBlock()
           Contains elements that specify the alignment, margins, and default tab stop positions of text in a shape's text block.
functiongetTextStyle()
functionsetTextStyle(value)
           StyleSheet from which this shape inherits text formatting.
functiongetTextXForm()
           Contains elements that specify positioning information about a shape's text block.
functiongetThreeDFormat()
           Gets the ThreeDFormat.
functiongetTwoD()
functionsetTwoD(value)
           Determines whether the shape behaves as a two-dimensional (2-D) object.
functiongetType()
functionsetType(value)
           The type of a shape. It may be one of the following values: Group, Shape, Guide, or Foreign. The value of the property is TypeValue integer constant.
functiongetUniqueID()
           A GUID (globally unique identifier) assigned to the shape.
functiongetUsers()
           Contains a collection of User elements.
functiongetXForm()
functionsetXForm(value)
           Contains elements specifying general positioning information about a shape.
functiongetXForm1D()
functionsetXForm1D(value)
           Contains x- and y-coordinates of the begin point and end point of a 1-D shape. This element appears for 1-D shapes only.
functiongetZOrderIndex()
           Returns the index of a shape in the z-order except the guide shape.
 
Method Summary
functionbringForward()
           Brings the shape forward one position in the z-order.
functionbringToFront()
           Brings the shape to the front of the z-order.
functionconnectedShapes(flag, categoryFilter)
           Returns an array that contains the identifiers (IDs) of the shapes that are connected to the shape.
functioncopy(source)
          
functiongetConnectorsType()
           Get Connectors type
functiongluedShapes(flag, categoryFilter, otherShape)
           Returns an array that contains the identifiers of the shapes that are glued to a shape.
functionisConnected(shape)
           Indicates whether this two shapes are connected.
functionisGlued(shape)
           Indicates whether this two shapes are glued.
functionisInGroup()
           Indicates whether this shape is in a group shape.
functionisIntersect(shape)
           Indicates whether this shape is intersect another shape.
functionmove(dX, dY)
           Moves shape on the dX and dY inches from current position.
functionmoveTo(newPinX, newPinY)
           Moves shape on new absolute position on the page.
functionrefreshData()
           Refreshes shape's position including xform ,connection and geom when changing shape's text or other's .
functionsendBackward()
           Moves the shape back one position in the z-order.
functionsendToBack()
           Moves the shape to the back of the z-order.
functionsetAngle(angle)
           Sets new angle of shape. The angle's unit is radian.
functionsetConnectorsType(type)
           Set Connectors type
functionsetHeight(height)
           Sets new height of shape.
functionsetWidth(width)
           Sets new width of shape.
functiontoHTML(fileName, options)
           Creates the html and saves it to a file.
functiontoImage(imageFile, options)
           Creates the shape image and saves it to a file. The extension of the file name determines the format of the image.
static functiontoImageStream(shape, stream, options)
           Creates the shape image and saves it to a stream in the specified format.
functiontoPdf(fileName)
           Saves the shape to a pdf file.
static functiontoPdfStream(shape, stream)
           Creates the shape pdf and saves it to a stream.
functiontoSvg(imageFile, options)
           Saves the shape to a svg file.
 

Constructor Detail

Shape

function Shape()
Constructor.

Property Getters/Setters Detail

getID/setID : long 

function getID() / function setID(value)
The unique ID of the element within its parent element.

getDel/setDel : Number 

function getDel() / function setDel(value)
A flag indicating whether the element is deleted locally. A value of 1 indicates that the element is deleted locally. The value of the property is BOOL integer constant.

getUniqueID : UUID 

function getUniqueID()
A GUID (globally unique identifier) assigned to the shape.

getName/setName : String 

function getName() / function setName(value)
The name of the element.

getNameU/setNameU : String 

function getNameU() / function setNameU(value)
The universal name of the element.

getType/setType : Number 

function getType() / function setType(value)
The type of a shape. It may be one of the following values: Group, Shape, Guide, or Foreign. The value of the property is TypeValue integer constant.

getLineStyle/setLineStyle : StyleSheet 

function getLineStyle() / function setLineStyle(value)
StyleSheet from which this shape inherits line formatting

getFillStyle/setFillStyle : StyleSheet 

function getFillStyle() / function setFillStyle(value)
StyleSheet from which this shape inherits fill formatting.

getTextStyle/setTextStyle : StyleSheet 

function getTextStyle() / function setTextStyle(value)
StyleSheet from which this shape inherits text formatting.

getShapes : ShapeCollection 

function getShapes()
Contains a collection of Shape elements.

getText/setText : Text 

function getText() / function setText(value)
Contains the text of a shape.

getXForm/setXForm : XForm 

function getXForm() / function setXForm(value)
Contains elements specifying general positioning information about a shape.

Example:

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");

diagram = new aspose.diagram.Diagram("RetrieveShapeInfo.vsd");

// Find a particular shape and update its foreground color and background color
for (it = diagram.getPages().get(0).getShapes().iterator(); it.hasNext();) {
    shape = it.next();
    if (shape.getNameU().toLowerCase() == "process") {
        shape.getXForm().getPinX().setValue(5);
        shape.getXForm().getPinY().setValue(5);
    }
}

diagram.save("out-SetXFormdata.vsdx", aspose.diagram.SaveFileFormat.VSDX);

getLine : Line 

function getLine()
Contains elements that control line attributes for a shape, such as pattern, weight, and color. These elements determine whether the line ends are formatted (for example, with an arrowhead), the size of line end formats, radius of the rounding circle applied to the line, and line cap style (round or square).

Example:

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");

diagram = new aspose.diagram.Diagram("RetrieveShapeInfo.vsd");

// get a shape by id
shape = diagram.getPages().getPage("Page-2").getShapes().getShape(1);

// set line dash type by index
shape.getLine().getLinePattern().setValue(4);
// set line weight, defualt in PT
shape.getLine().getLineWeight().setValue(2);
// set color of the shape's line
shape.getLine().getLineColor().getUfe().setF("RGB(95,108,53)");
// set line rounding, default in inch
shape.getLine().getRounding().setValue(0.3125);
// set line caps
shape.getLine().getLineCap().setValue(aspose.diagram.BOOL.TRUE);
// set line color transparency in percent
shape.getLine().getLineColorTrans().setValue(50);

// add arrows to the connector or curve shapes
// select arrow type by index
shape.getLine().getBeginArrow().setValue(4);
shape.getLine().getEndArrow().setValue(4);
// set arrow size
shape.getLine().getBeginArrowSize().setValue(aspose.diagram.ArrowSizeValue.SMALL);
shape.getLine().getBeginArrowSize().setValue(aspose.diagram.ArrowSizeValue.SMALL);

diagram.save("out-SetLineData.vsdx", aspose.diagram.SaveFileFormat.VSDX);

getFill : Fill 

function getFill()
Contains the current fill formatting values for the shape and the shape's drop shadow, including pattern, foreground color, and background color.

Example:

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");

diagram = new aspose.diagram.Diagram("RetrieveShapeInfo.vsd");

// Find a particular shape and update its foreground color and background color
for (it = diagram.getPages().get(0).getShapes().iterator(); it.hasNext();) {
    shape = it.next();
    if (shape.getNameU().toLowerCase() == "process") {
        shape.getFill().getFillForegnd().setValue("#ebf8df");
        shape.getFill().getFillBkgnd().setValue("#dff8eb");
    }
}

diagram.save("out-SetFillData.vsdx", aspose.diagram.SaveFileFormat.VSDX);

getInheritChars : CharCollection 

function getInheritChars()
Contains the char values for the shape inherit by the master shape.

getInheritProps : PropCollection 

function getInheritProps()
Contains the props for the shape inherit by the master shape.

getInheritUsers : UserCollection 

function getInheritUsers()
Contains the users for the shape inherit by the master shape.

getInheritLine : Line 

function getInheritLine()
Contains the line formatting values for the shape inherit by the parent style and the master shape.

getInheritFill : Fill 

function getInheritFill()
Contains the fill formatting values for the shape inherit by the parent style and the master shape.

getXForm1D/setXForm1D : XForm1D 

function getXForm1D() / function setXForm1D(value)
Contains x- and y-coordinates of the begin point and end point of a 1-D shape. This element appears for 1-D shapes only.

getEvent/setEvent : Event 

function getEvent() / function setEvent(value)
Contains elements that specify formulas that control shape events.

getLayerMem : LayerMem 

function getLayerMem()
Contains the LayerMember element, which specifies each layer to which the shape is assigned.

Example:

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");

diagram = new aspose.diagram.Diagram("Layers.vsdx");
shapes = diagram.getPages().getPage("Page-1").getShapes();
// iterate through the shapes
for (var it = shapes.iterator(); it.hasNext();) {
    shape = it.next();
    if (shape.getName().toLowerCase() == "shape1") {
        // Add shape1 in first two layers. Here "0;1" are indexes of the
        // layers
        layer = shape.getLayerMem();
        layer.getLayerMember().setValue("0;1");
    } else if (shape.getName().toLowerCase() == "shape2") {
        // Remove shape2 from all the layers
        layer = shape.getLayerMem();
        layer.getLayerMember().setValue("");
    } else if (shape.getName().toLowerCase() == "shape3") {
        // Add shape3 in first layer. Here "0" is index of the first
        // layer
        layer = shape.getLayerMem();
        layer.getLayerMember().setValue("0");
    }
}
// save diagram
diagram.save("out-ConfigureShapeLayers.vsdx", aspose.diagram.SaveFileFormat.VSDX);

getForeign : Foreign 

function getForeign()
Contains elements specifying the width and height of an object from another program used in a Microsoft Visio document. Also includes elements specifying the distance the object's image is offset within its borders.

getTextBlock : TextBlock 

function getTextBlock()
Contains elements that specify the alignment, margins, and default tab stop positions of text in a shape's text block.

Example:

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");

diagram = new aspose.diagram.Diagram("TextBoxes.vsdx");

// get the page by its name
page1 = diagram.getPages().getPage("Page-1");
// get shape by its ID
shape = page1.getShapes().getShape(1);
// set orientation angle
margin = new aspose.diagram.DoubleValue(4, aspose.diagram.MeasureConst.PT);

// set left, right, top and bottom margins of the shape's text block
shape.getTextBlock().setLeftMargin(margin);
shape.getTextBlock().setRightMargin(margin);
shape.getTextBlock().setTopMargin(margin);
shape.getTextBlock().setBottomMargin(margin);

// set the text direction
shape.getTextBlock().getTextDirection().setValue(aspose.diagram.TextDirectionValue.VERTICAL);
// set the text alignment
shape.getTextBlock().getVerticalAlign().setValue(aspose.diagram.VerticalAlignValue.MIDDLE);
// set the text block background color
shape.getTextBlock().getTextBkgnd().getUfe().setF("RGB(95,108,53)");
// set the background color transparency in percent
shape.getTextBlock().getTextBkgndTrans().setValue(50);
// set the distance between default tab stops for the selected shape.
shape.getTextBlock().getDefaultTabStop().setValue(2);
    
diagram.save("out-FormatShapeTextBlockSection.vsdx", aspose.diagram.SaveFileFormat.VSDX);

getTextXForm : TextXForm 

function getTextXForm()
Contains elements that specify positioning information about a shape's text block.

Example:

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");

diagram = new aspose.diagram.Diagram("TextBoxes.vsdx");

// get shape
shape = diagram.getPages().getPage("Page-1").getShapes().getShape(1);

// set text position at the bottom,
// TxtLocPinY = "TxtHeight*1" and TxtPinY = "Height*0"
shape.getTextXForm().getTxtLocPinY().setValue(shape.getTextXForm().getTxtHeight().getValue());
shape.getTextXForm().getTxtPinY().setValue(0);

// set orientation angle
angleDeg = 0;
angleRad = (Math.PI / 180) * angleDeg;
shape.getTextXForm().getTxtAngle().setValue(angleRad);
    
diagram.save("out-SetShapeTextPositionAtBottom.vsdx", aspose.diagram.SaveFileFormat.VSDX);

getAlign : Align 

function getAlign()
Indicates the alignment of a shape with respect to the guide or guide point to which the shape is glued. The Align element appears only for shapes that are glued to guides or guide points.

getProtection : Protection 

function getProtection()
Locking helps prevent inadvertent changes to the shape but does not prevent Microsoft Visio from resetting values in other circumstances. It also does not protect against changes made in the ShapeSheet window.

getHelp : Help 

function getHelp()
Contains elements specifying the Shape element's Help file topic and copyright information.

getMisc : Misc 

function getMisc()
Contains elements specifying the Shape element's Help file topic and copyright information.

getImage : Image 

function getImage()
Contains the gamma, brightness, contrast, blur, sharpen, denoise, and transparency values for a bitmap.

getGroup : Group 

function getGroup()
Contains elements that control how you add shapes to a group, move members of a group, and select groups.

getLayout : Layout 

function getLayout()
Contains elements that control shape placement and connector routing settings.

getChars : CharCollection 

function getChars()
Contains a collection of Char elements.

Example:

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");

diagram = new aspose.diagram.Diagram("ApplyFontOnText.vsdx");

sourceShape = null;
// get page by name
page = diagram.getPages().getPage("Page-1");
// get shape by ID
shape = page.getShapes().getShape(1);
// clear shape text values and chars
shape.getText().getValue().clear();
shape.getChars().clear();

// mark character run and add text
shape.getText().getValue().add(new aspose.diagram.Cp(0));
shape.getText().getValue().add(new aspose.diagram.Txt("TextStyle_Regular\n"));
shape.getText().getValue().add(new aspose.diagram.Cp(1));
shape.getText().getValue().add(new aspose.diagram.Txt("TextStyle_Bold_Italic\n"));
shape.getText().getValue().add(new aspose.diagram.Cp(2));
shape.getText().getValue().add(new aspose.diagram.Txt("TextStyle_Underline_Italic\n"));
shape.getText().getValue().add(new aspose.diagram.Cp(3));
shape.getText().getValue().add(new aspose.diagram.Txt("TextStyle_Bold_Italic_Underline"));

// add formatting characters
shape.getChars().add(new aspose.diagram.Char());
shape.getChars().add(new aspose.diagram.Char());
shape.getChars().add(new aspose.diagram.Char());
shape.getChars().add(new aspose.diagram.Char());

// set properties e.g. color, font, size and style etc.
shape.getChars().get(0).setIX(0);
shape.getChars().get(0).getColor().setValue("#FF0000");
shape.getChars().get(0).getFont().setValue(4);
shape.getChars().get(0).getSize().setValue(0.22);
shape.getChars().get(0).getStyle().setValue(aspose.diagram.StyleValue.UNDEFINED);

// set properties e.g. color, font, size and style etc.
shape.getChars().get(1).setIX(1);
shape.getChars().get(1).getColor().setValue("#FF00FF");
shape.getChars().get(1).getFont().setValue(4);
shape.getChars().get(1).getSize().setValue(0.22);
shape.getChars().get(1).getStyle().setValue(aspose.diagram.StyleValue.BOLD |aspose.diagram. StyleValue.ITALIC);

// set properties e.g. color, font, size and style etc.
shape.getChars().get(2).setIX(2);
shape.getChars().get(2).getColor().setValue("#00FF00");
shape.getChars().get(2).getFont().setValue(4);
shape.getChars().get(2).getSize().setValue(0.22);
shape.getChars().get(2).getStyle().setValue(aspose.diagram.StyleValue.UNDERLINE | aspose.diagram.StyleValue.ITALIC);

// set properties e.g. color, font, size and style etc.
shape.getChars().get(3).setIX(3);
shape.getChars().get(3).getColor().setValue("#3333FF");
shape.getChars().get(3).getFont().setValue(4);
shape.getChars().get(3).getSize().setValue(0.22);
shape.getChars().get(3).getStyle().setValue(aspose.diagram.StyleValue.BOLD | aspose.diagram.StyleValue.ITALIC | aspose.diagram.StyleValue.UNDERLINE);

diagram.save("out-ApplyFontOnText.vsdx", aspose.diagram.SaveFileFormat.VSDX);

getParas : ParaCollection 

function getParas()
Contains a collection of Para elements.

getScratchs : ScratchCollection 

function getScratchs()
Contains a collection of Scratch elements.

getConnections : ConnectionCollection 

function getConnections()
Contains a collection of Connection elements.

getConnectionABCDs : ConnectionABCDCollection 

function getConnectionABCDs()
Contains a collection of ConnectionABCD elements.

getFields : FieldCollection 

function getFields()
Contains a collection of Field elements.

getControls : ControlCollection 

function getControls()
Contains a collection of Control elements.

getGeoms : GeomCollection 

function getGeoms()
Contains a collection of Geom elements.

getActs : ActCollection 

function getActs()
Contains a collection of Act elements.

getUsers : UserCollection 

function getUsers()
Contains a collection of User elements.

Example:

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");

diagram = new aspose.diagram.Diagram("TextBoxes.vsdx");

// get page by name
page = diagram.getPages().getPage("Page-1");
// get shape by id
shape = page.getShapes().getShape(2);
// extract user defined cells of the shape
for (it = shape.getUsers().iterator(); it.hasNext();) {
    user = it.next();
    console.log(user.getName() + ": " + user.getValue().getVal());
}

getProps/setProps : PropCollection 

function getProps() / function setProps(value)
Contains a collection of Prop elements.

getHyperlinks : HyperlinkCollection 

function getHyperlinks()
Contains a collection of Hyperlink elements.

Example:

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");

diagram = new aspose.diagram.Diagram("Hyperlinks.vsdx");

// get page by name
var page = diagram.getPages().getPage("Page-1");
// get shape by ID
var shape = page.getShapes().getShape(1);
// get hyperlink collection
var hyperlinks = shape.getHyperlinks();
// iterate through the hyperlinks
for (var it = hyperlinks.iterator(); it.hasNext();) {
    hyperlink = it.next();
    console.log("Address: " + hyperlink.getAddress().getValue());
    console.log("Sub Address: " + hyperlink.getSubAddress().getValue());
    console.log("Description: " + hyperlink.getDescription().getValue());
}

getSmartTagDefs : SmartTagDefCollection 

function getSmartTagDefs()
Contains a collection of SmartTagDef elements.

getTabsCollection : TabsCollection 

function getTabsCollection()
Contains a collection of Tab elements.

getData1/setData1 : String 

function getData1() / function setData1(value)
Contains an arbitrary string value that is used to supply additional information about a shape.

getData2/setData2 : String 

function getData2() / function setData2(value)
Contains an arbitrary string value that is used to supply additional information about a shape.

getData3/setData3 : String 

function getData3() / function setData3(value)
Contains an arbitrary string value that is used to supply additional information about a shape.

getForeignData : ForeignData 

function getForeignData()
Contains a MIME (Multipurpose Internet Mail Extensions) encoded BLOB of picture data, such as Windows metafile, bitmap, or OLE data.

Example:

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
fs = require("fs");

diagram = new aspose.diagram.Diagram("ExtractAllImagesFromPage.vsd");

// Enter page index i.e. 0 for first one
for (var it = diagram.getPages().getPage(0).getShapes().iterator(); it.hasNext();) {
    shape = it.next();
    // Filter shapes by type Foreign
    if (shape.getType() == aspose.diagram.TypeValue.FOREIGN) {
        output = fs.writeFileSync("out" + shape.getID() + ".bmp", shape.getForeignData().getValue());
    }
}

getMasterShape/setMasterShape : Shape 

function getMasterShape() / function setMasterShape(value)
This attribute may only be present in shapes that are members of a group shape, and the group is an instance of a master. The attribute contains an ID that references the corresponding sub-shape in the master.

getMaster/setMaster : Master 

function getMaster() / function setMaster(value)
The Master from which the shape inherits its data.

getParentShape/setParentShape : Shape 

function getParentShape() / function setParentShape(value)
Shape's parent.

Example:

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");

diagram = new aspose.diagram.Diagram("AddingNewShape.vsdx");

// get a sub-shape by page name, group shape ID, and then sub-shape ID
shape = diagram.getPages().getPage("Page-3").getShapes().getShape(13).getShapes().getShape(2);
parentShape = shape.getParentShape();
console.log("Parent Shape's Properties:");
console.log("Shape ID: " + parentShape.getID());
console.log("Shape Name: " + parentShape.getName());
console.log("Shape Type: " + parentShape.getType());

getDiagram/setDiagram : Diagram 

function getDiagram() / function setDiagram(value)
Root element of Visio objects hierarchy.

getPage/setPage : Page 

function getPage() / function setPage(value)
Root element of Visio objects hierarchy.

getOneD : boolean 

function getOneD()
Determines whether the shape behaves as a one-dimensional (1-D) object. Read-only.

getTwoD/setTwoD : boolean 

function getTwoD() / function setTwoD(value)
Determines whether the shape behaves as a two-dimensional (2-D) object.

isTextEmpty : boolean 

function isTextEmpty()
Indicate the shape has text and the text is empty or not.

getControlData : byte[] 

function getControlData()
Gets the data of control.

getActiveXControl : ActiveXControl 

function getActiveXControl()
Gets the ActiveX control.

Example:

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");

diagram = new aspose.diagram.Diagram("VisioActiveXControls.vsdx");

// get a Visio page by name
page = diagram.getPages().getPage("Page-1");
// get a shape by ID
shape = page.getShapes().getShape(1);
// get an ActiveX control
activex = shape.getActiveXControl();
// set width of the command button control
activex.setWidth(4);
// set height of the command button control
activex.setHeight(4);
// set caption of the command button control
activex.setCaption("Test Button");
    
diagram.save("out-RetrieveActiveXControl.vsdx", aspose.diagram.SaveFileFormat.VSDX);

getZOrderIndex : Number 

function getZOrderIndex()
Returns the index of a shape in the z-order except the guide shape.

getThreeDFormat : ThreeDFormat 

function getThreeDFormat()
Gets the ThreeDFormat.

Method Detail

toPdf

function toPdf(fileName)
Saves the shape to a pdf file.
Parameters:
fileName: String - the pdf file name with full path

toImage

function toImage(imageFile, options)
Creates the shape image and saves it to a file. The extension of the file name determines the format of the image.

The format of the image is specified by using the extension of the file name. For example, if you specify "myfile.png", then the image will be saved in the PNG format. The following file extensions are recognized: .bmp, .gif, .png, .jpg, .jpeg, .tiff, .tif, .emf.

Parameters:
imageFile: String - The image file name with full path.
options: ImageSaveOptions - Addtional image creation options

toSvg

function toSvg(imageFile, options)
Saves the shape to a svg file.
Parameters:
fileName - the svg file name with full path

toHTML

function toHTML(fileName, options)
Creates the html and saves it to a file.
Parameters:
imageFile - The file name with full path.
options: HTMLSaveOptions - html save options

getConnectorsType

function getConnectorsType()
Get Connectors type

setConnectorsType

function setConnectorsType(type)
Set Connectors type
Parameters:
type - A ConnectorsTypeValue value.

Example:

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");

diagram = new aspose.diagram.Diagram("RetrieveShapeInfo.vsd");

// get a dynamic connector type shape by id
shape = diagram.getPages().getPage("Page-2").getShapes().getShape(3);

// set dynamic connector appearance
shape.setConnectorsType(aspose.diagram.ConnectorsTypeValue.STRAIGHT_LINES);

diagram.save("out-SetConnectorAppearance.vsdx", aspose.diagram.SaveFileFormat.VSDX);

copy

function copy(source)

bringForward

function bringForward()
Brings the shape forward one position in the z-order.

sendBackward

function sendBackward()
Moves the shape back one position in the z-order.

bringToFront

function bringToFront()
Brings the shape to the front of the z-order.

sendToBack

function sendToBack()
Moves the shape to the back of the z-order.

connectedShapes

function connectedShapes(flag, categoryFilter)
Returns an array that contains the identifiers (IDs) of the shapes that are connected to the shape.
Parameters:
flag: Number - A ConnectedShapesFlags value. Filters the array of returned shape IDs by the directionality of the connectors. See Remarks for possible valuesConnectedShapesFlags.
categoryFilter: String - Filters the array of returned shape IDs by limiting it to the IDs of shapes that match the specified categoryjava.lang.String.
Returns:
IDs arraylong.

Example:

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");

diagram = new aspose.diagram.Diagram("AddingNewShape.vsdx");

// get shape by id
shape = diagram.getPages().getPage("Page-3").getShapes().getShape(16);
// get connected shapes
connectedShapeIds = shape.connectedShapes(aspose.diagram.ConnectedShapesFlags.CONNECTED_SHAPES_ALL_NODES, null);

for (let i = 0; i < connectedShapeIds.length; i++) {
    shape = diagram.getPages().getPage("Page-3").getShapes().getShape(connectedShapeIds[i]);
    console.log("ID: " + shape.getID() + "\t\t Name: " + shape.getName());
}

isInGroup

function isInGroup()
Indicates whether this shape is in a group shape.

Example:

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");

diagram = new aspose.diagram.Diagram("AddingNewShape.vsdx");

// get a sub-shape by page name, group shape ID, and then sub-shape ID
shape = diagram.getPages().getPage("Page-3").getShapes().getShape(13).getShapes().getShape(2);
console.log("Is it in a Group: " + shape.isInGroup());

isIntersect

function isIntersect(shape)
Indicates whether this shape is intersect another shape.

isConnected

function isConnected(shape)
Indicates whether this two shapes are connected.
Parameters:
shape: Shape - shape

Example:

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");

diagram = new aspose.diagram.Diagram("RetrieveShapeInfo.vsd");

// get Visio page by name
page = diagram.getPages().getPage("Page-2");

// get Visio shapes by ids
ShapedOne = page.getShapes().getShape(1);
ShapedTwo = page.getShapes().getShape(2);

// determine whether shapes are connected
connected = ShapedOne.isConnected(ShapedTwo);
console.log("Shapes are connected: " + connected);

// determine whether shapes are glued
glued = ShapedOne.isGlued(ShapedTwo);
console.log("Shapes are Glued: " + glued);

isGlued

function isGlued(shape)
Indicates whether this two shapes are glued.
Parameters:
shape: Shape - shape

refreshData

function refreshData()
Refreshes shape's position including xform ,connection and geom when changing shape's text or other's . We will gather shape's data such as shape's text then calculate shape's position. This method is only used to refresh shape's data .

Example:

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");

diagram = new aspose.diagram.Diagram("AddingNewShape.vsdx");

// get page by name
page = diagram.getPages().getPage("Page-2");

// Add master with stencil file path and master id
masterName = "Rectangle";
// Add master with stencil file path and master name
diagram.addMaster("BasicShapes.vss", masterName);

// page indexing starts from 0
PageIndex = 1;
width = 2, height = 2, pinX = 4.25, pinY = 4.5;
// Add a new rectangle shape
rectangleId = diagram.addShape(pinX, pinY, width, height, masterName, PageIndex);

// set shape properties
rectangle = page.getShapes().getShape(rectangleId);
rectangle.getXForm().getPinX().setValue(5);
rectangle.getXForm().getPinY().setValue(5);
rectangle.setType(aspose.diagram.TypeValue.SHAPE);
rectangle.getText().getValue().add(new aspose.diagram.Txt("Aspose Diagram"));
rectangle.setTextStyle(diagram.getStyleSheets().get(3));
rectangle.getLine().getLineColor().setValue("#ff0000");
rectangle.getLine().getLineWeight().setValue(0.03);
rectangle.getLine().getRounding().setValue(0.1);
rectangle.getFill().getFillBkgnd().setValue("#ff00ff");
rectangle.getFill().getFillForegnd().setValue("#ebf8df");

rectangle.refreshData();

diagram.save("out-AddShape.vsdx", aspose.diagram.SaveFileFormat.VSDX);

gluedShapes

function gluedShapes(flag, categoryFilter, otherShape)
Returns an array that contains the identifiers of the shapes that are glued to a shape.
Parameters:
flag: Number - A GluedShapesFlags value. The dimensionality and directionality of the connection points of the shapes to return.See Remarks for possible valuesGluedShapesFlags.
categoryFilter: String - Filters the array of returned shape IDs by limiting it to the IDs of shapes that match the specified categoryjava.lang.String.
otherShape: Shape - Optional: additional shape to which returned shapes must also be glued, can be Shape or null.
Returns:
IDs arraylong.

Example:

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");

diagram = new aspose.diagram.Diagram("RetrieveShapeInfo.vsd");

// get shape by an ID
shape = diagram.getPages().getPage("Page-2").getShapes().getShape(1);
// get all glued 1D shapes
gluedShapeIds = shape.gluedShapes(aspose.diagram.GluedShapesFlags.GLUED_SHAPES_ALL_1_D, null, null);

// display shape ID and name
for (let i = 0; i < gluedShapeIds.length; i++) {
    shape = diagram.getPages().get(0).getShapes().getShape(gluedShapeIds[i]);
    console.log("ID: " + shape.getID() + "\t\t Name: " + shape.getName());
}

setWidth

function setWidth(width)
Sets new width of shape.
Parameters:
width: Number - New widthdouble.

setHeight

function setHeight(height)
Sets new height of shape.
Parameters:
height: Number - New heigthdouble.

setAngle

function setAngle(angle)
Sets new angle of shape. The angle's unit is radian.
Parameters:
angle: Number - New angle which unit is radian not degreedouble.

Example:

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");

diagram = new aspose.diagram.Diagram("RetrieveShapeInfo.vsd");

shape = diagram.getPages().getPage("Page-2").getShapes().getShape(2);

// Add a shape and set the angle
shape.setAngle(190);

diagram.save("out-RotateVisioShape.vsdx", aspose.diagram.SaveFileFormat.VSDX);

moveTo

function moveTo(newPinX, newPinY)
Moves shape on new absolute position on the page.
Parameters:
newPinX: Number - New x-coordinate of the shape's pin (center of rotation) in relation to the origin of its parent.double.
newPinY: Number - New y-coordinate of the shape's pin (center of rotation) in relation to the origin of its parent.double.

move

function move(dX, dY)
Moves shape on the dX and dY inches from current position.
Parameters:
dX: Number - X offsetdouble.
dY: Number - Y offsetdouble.

Example:

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");

diagram = new aspose.diagram.Diagram("GroupShapes.vsdx");

// get page by name
page = diagram.getPages().getPage("Page-3");
// get shape by id
shape = page.getShapes().getShape(16);
// move shape from its position, it adds values in coordinates
shape.move(1, 1);

diagram.save("out-MoveVisioShape.vsdx", aspose.diagram.SaveFileFormat.VSDX);

toPdfStream

static function toPdfStream(shape, stream)
Creates the shape pdf and saves it to a stream.
Parameters:
shape: Shape - The shape object to save
stream: WritableStream - The stream

Example:

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
var fs = require("fs");

var diagram = new aspose.diagram.Diagram("example.vsdx");
var page = diagram.getPages().getPage("Page-1");
var shape = page.getShapes().getShape(1);
var writeStream = fs.createWriteStream("output.pdf");
aspose.diagram.Shape.toPdfStream(shape, writeStream);
				

toImageStream

static function toImageStream(shape, stream, options)
Creates the shape image and saves it to a stream in the specified format.
Parameters:
shape: Shape - The shape object to save
stream: WritableStream - The stream
options: ImageSaveOptions - ImageSaveOptions Addtional image creation options.

Example:

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
var fs = require("fs");

var diagram = new aspose.diagram.Diagram("example.vsdx");
var page = diagram.getPages().getPage("Page-1");
var shape = page.getShapes().getShape(1);
var writeStream = fs.createWriteStream("output.png");
var options = new aspose.diagram.ImageSaveOptions(aspose.diagram.SaveFileFormat.PNG);
aspose.diagram.Shape.toImageStream(shape, writeStream, options);
				

See Also:
          Aspose.Cells Documentation - the home page for the Aspose.Cellss Product Documentation.
          Aspose.Cells Support Forum - our preferred method of support.