Methods

new Diagram()

Methods

static

createDiagramFromStream(stream, callback)

Public class constructor, loads the diagram from the stream.

Example

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
var fs = require("fs");
var readStream = fs.createReadStream("example.vsdx");
aspose.diagram.Diagram.createDiagramFromStream(readStream, function(diagram, err) {
if (err) {
console.log("open error");
return;
}
diagram.save("output.vsdx", aspose.diagram.SaveFileFormat.VSDX);
});

Parameters

Name Type Optional Description

stream

ReadableStream

 

The data stream

callback

Callback

 

The callback function

static

createDiagramFromStream(stream, format, callback)

Public class constructor, loads the diagram from the stream using predefined format.

Example

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
var fs = require("fs");
var readStream = fs.createReadStream("example.vsdx");
aspose.diagram.Diagram.createDiagramFromStream(readStream, aspose.diagram.LoadFileFormat.VSDX, function(diagram, err) {
if (err) {
console.log("open error");
return;
}
diagram.save("output.vsdx", aspose.diagram.SaveFileFormat.VSDX);
});

Parameters

Name Type Optional Description

stream

ReadableStream

 

The data stream

format

Number

 

A

callback

Callback

 

The callback function

static

createDiagramFromStream(stream, options, callback)

Public class constructor, loads the diagram from the file using predefined load file options.

Example

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
var fs = require("fs");
var readStream = fs.createReadStream("example.vsdx");
options = new aspose.diagram.LoadOptions(aspose.diagram.LoadFileFormat.VSDX);
aspose.diagram.Diagram.createDiagramFromStream(readStream, options, function(diagram, err) {
if (err) {
console.log("open error: " + err);
return;
}
diagram.save("output.vsdx", aspose.diagram.SaveFileFormat.VSDX);
});

Parameters

Name Type Optional Description

stream

ReadableStream

 

The data stream

options

LoadOptions

 

The data

callback

Callback

 

The callback function

static

save(diagram, stream, saveFormat)

Saves the diagram data to the stream.

Example

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
var fs = require("fs");
var diagram = new aspose.diagram.Diagram("example.vsdx");
var writeStream = fs.createWriteStream("output-stream.vsdx");
aspose.diagram.Diagram.saveToStream(diagram, writeStream, aspose.diagram.SaveFileFormat.VSDX);

Parameters

Name Type Optional Description

diagram

Diagram

 

The diagram object to save

stream

WritableStream

 

The stream

saveFormat

Number

 

A

static

save(diagram, stream, options)

Saves the diagram to a file using the specified save options.

Example

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
var fs = require("fs");
var diagram = new aspose.diagram.Diagram("example.vsdx");
var writeStream = fs.createWriteStream("output-stream.vsdx");
var options = new aspose.diagram.DiagramSaveOptions(aspose.diagram.SaveFileFormat.VSDX);
aspose.diagram.Diagram.saveToStream(diagram, writeStream, options);

Parameters

Name Type Optional Description

diagram

Diagram

 

The diagram object to save

stream

WritableStream

 

The stream

options

SaveOptions

 

SaveOptions

addMaster(srcDiagram, masterName) → Number

Adds master to diagram from source diagram by master's Name or NameU.

Example

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
diagram = new aspose.diagram.Diagram();
templateFileName = "NetApp-FAS-series.vss";
// Add master with stencil file path and master id
masterName = "FAS80xx rear empty";
diagram.addMaster(templateFileName, 2);
// Add master with stencil file path and master name
diagram.addMaster(templateFileName, masterName);
// adds master to diagram from source diagram
src = new aspose.diagram.Diagram(templateFileName);
diagram.addMaster(src, masterName);
// Adds shape with defined PinX and PinY.
diagram.addShape(2.0, 2.0, masterName, 0);
diagram.addShape(6.0, 6.0, masterName, 0);
// Adds shape with defined PinX,PinY,Width and Height.
diagram.addShape(7.0, 3.0, 1.5, 1.5, masterName, 0);
// Save resultant Image file
diagram.save("out-AddMasterFromStencil.vsdx", aspose.diagram.SaveFileFormat.VSDX);

Parameters

Name Type Optional Description

srcDiagram

Diagram

 

source diagram.

masterName

String

 

Master's Name or NameU.

Returns

Number The unique ID of the master within masters collection in this diagram.

addMaster(templateFilePath, masterName) → Number

Adds master to diagram from template file by master's Name or NameU.

Example

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
diagram = new aspose.diagram.Diagram();
templateFileName = "NetApp-FAS-series.vss";
// Add master with stencil file path and master id
masterName = "FAS80xx rear empty";
diagram.addMaster(templateFileName, 2);
// Add master with stencil file path and master name
diagram.addMaster(templateFileName, masterName);
// adds master to diagram from source diagram
src = new aspose.diagram.Diagram(templateFileName);
diagram.addMaster(src, masterName);
// Adds shape with defined PinX and PinY.
diagram.addShape(2.0, 2.0, masterName, 0);
diagram.addShape(6.0, 6.0, masterName, 0);
// Adds shape with defined PinX,PinY,Width and Height.
diagram.addShape(7.0, 3.0, 1.5, 1.5, masterName, 0);
// Save resultant Image file
diagram.save("out-AddMasterFromStencil.vsdx", aspose.diagram.SaveFileFormat.VSDX);

Parameters

Name Type Optional Description

templateFilePath

String

 

Path to template file(can be vdx, vst or vsd format).

masterName

String

 

Master's Name or NameU.

Returns

Number The unique ID of the master within masters collection in this diagram.

addMaster(templateFilePath, masterID) → Number

Adds master to diagram from template file by master's ID.

Example

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
diagram = new aspose.diagram.Diagram();
templateFileName = "NetApp-FAS-series.vss";
// Add master with stencil file path and master id
masterName = "FAS80xx rear empty";
diagram.addMaster(templateFileName, 2);
// Add master with stencil file path and master name
diagram.addMaster(templateFileName, masterName);
// adds master to diagram from source diagram
src = new aspose.diagram.Diagram(templateFileName);
diagram.addMaster(src, masterName);
// Adds shape with defined PinX and PinY.
diagram.addShape(2.0, 2.0, masterName, 0);
diagram.addShape(6.0, 6.0, masterName, 0);
// Adds shape with defined PinX,PinY,Width and Height.
diagram.addShape(7.0, 3.0, 1.5, 1.5, masterName, 0);
// Save resultant Image file
diagram.save("out-AddMasterFromStencil.vsdx", aspose.diagram.SaveFileFormat.VSDX);

Parameters

Name Type Optional Description

templateFilePath

String

 

Path to template file(can be vdx, vst or vsd format).

masterID

Number

 

The unique ID of the master within masters collection in template.

Returns

Number The unique ID of the master within masters collection in this diagram.

addShape(newShape, masterName, pageNumber) → long

Adds shape created by master to specific page.

Parameters

Name Type Optional Description

newShape

Shape

 

New shape object

masterName

String

 

Master's name.

pageNumber

Number

 

Index of page.

Returns

long The unique ID of the shape within shapes collection on the specified page.

addShape(pinX, pinY, masterName, pageNumber) → long

Adds shape created by master on page with defined PinX and PinY.

Example

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
diagram = new aspose.diagram.Diagram();
templateFileName = "NetApp-FAS-series.vss";
// Add master with stencil file path and master id
masterName = "FAS80xx rear empty";
diagram.addMaster(templateFileName, 2);
// Add master with stencil file path and master name
diagram.addMaster(templateFileName, masterName);
// adds master to diagram from source diagram
src = new aspose.diagram.Diagram(templateFileName);
diagram.addMaster(src, masterName);
// Adds shape with defined PinX and PinY.
diagram.addShape(2.0, 2.0, masterName, 0);
diagram.addShape(6.0, 6.0, masterName, 0);
// Adds shape with defined PinX,PinY,Width and Height.
diagram.addShape(7.0, 3.0, 1.5, 1.5, masterName, 0);
// Save resultant Image file
diagram.save("out-AddMasterFromStencil.vsdx", aspose.diagram.SaveFileFormat.VSDX);

Parameters

Name Type Optional Description

pinX

Number

 

Specifies the x-coordinate of the shape's pin (center of rotation) in relation to the page.

pinY

Number

 

Specifies the y-coordinate of the shape's pin (center of rotation) in relation to the page.

masterName

String

 

Master's name.

pageNumber

Number

 

Index of page.

Returns

long The unique ID of the shape within shapes collection on the specified page.

addShape(pinX, pinY, width, height, masterName, pageNumber) → long

Adds shape created by master on page with defined PinX,PinY,Width and Height.

Example

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
diagram = new aspose.diagram.Diagram();
templateFileName = "NetApp-FAS-series.vss";
// Add master with stencil file path and master id
masterName = "FAS80xx rear empty";
diagram.addMaster(templateFileName, 2);
// Add master with stencil file path and master name
diagram.addMaster(templateFileName, masterName);
// adds master to diagram from source diagram
src = new aspose.diagram.Diagram(templateFileName);
diagram.addMaster(src, masterName);
// Adds shape with defined PinX and PinY.
diagram.addShape(2.0, 2.0, masterName, 0);
diagram.addShape(6.0, 6.0, masterName, 0);
// Adds shape with defined PinX,PinY,Width and Height.
diagram.addShape(7.0, 3.0, 1.5, 1.5, masterName, 0);
// Save resultant Image file
diagram.save("out-AddMasterFromStencil.vsdx", aspose.diagram.SaveFileFormat.VSDX);

Parameters

Name Type Optional Description

pinX

Number

 

Specifies the x-coordinate of the shape's pin (center of rotation) in relation to the page.

pinY

Number

 

Specifies the y-coordinate of the shape's pin (center of rotation) in relation to the page.

width

Number

 

Specifies the width of the shape in inches.

height

Number

 

Specifies the height of the shape in inches.

masterName

String

 

Master's name.

pageNumber

Number

 

Index of page.

Returns

long The unique ID of the shape within shapes collection on the specified page.

combine(secondDiagram)

Combines another Diagram object.

Parameter

Name Type Optional Description

secondDiagram

Diagram

 

Another Diagram object.

constructor_overload$1(filename)

Public class constructor, loads the diagram from the file.

Parameter

Name Type Optional Description

filename

String

 

The file name.

constructor_overload$2(filename, format)

Public class constructor, loads the diagram from the file using predefined format.

Parameters

Name Type Optional Description

filename

String

 

The file name.

format

Number

 

LoadFileFormat

constructor_overload$3(filename, options)

Public class constructor, loads the diagram from the file using predefined load file options.

Parameters

Name Type Optional Description

filename

String

 

The file name.

options

LoadOptions

 

The data

copyTheme(source)

Copies Theme from a source Diagram.

Parameter

Name Type Optional Description

source

Diagram

 

source diagram.

dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

getActivePage()

Specifies the active page

getBuildnum()

The build number of the Visio instance used to create the document.

getColors()

Contains the document's color table. Each document contains a single color table, which lists the 24 standard colors that are available for application to objects such as shapes, text, and layers in the document.

getDataConnections()

Contains the DataConnection elements for the document.

getDataRecordSets()

The collection of DataRecordset objects associated with a Document object.

getDefaultFontDir()

Get the Default Fonts folder path

Example

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
diagram = new aspose.diagram.Diagram("RetrieveFontInfo.vsd");
console.log(diagram.getDefaultFontDir());

getDocLangID()

The unique ID of the user-interface language the user has specified in Microsoft Office 2010 Language Preferences.

getDocumentProps()

Contains document property elements such as the document's title, author, and so on.

Example

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
diagram = new aspose.diagram.Diagram("Introduction.vsdx");
// Display Visio version and document modification time at different stages
console.log("Visio Instance Version : " + diagram.getVersion());
console.log("Full Build Number Created : " + diagram.getDocumentProps().getBuildNumberCreated());
console.log("Full Build Number Edited : " + diagram.getDocumentProps().getBuildNumberEdited());
console.log("Date Created : " + diagram.getDocumentProps().getTimeCreated());
console.log("Date Last Edited : " + diagram.getDocumentProps().getTimeEdited());
console.log("Date Last Printed : " + diagram.getDocumentProps().getTimePrinted());
console.log("Date Last Saved : " + diagram.getDocumentProps().getTimeSaved());

getDocumentSettings()

Contains elements that specify document settings.

getDocumentSheet()

Specifies a document's ShapeSheet structure.

getEmailRoutingData()

Contains a MIME (Multipurpose Internet Mail Extensions) encoded MAPI e-mail routing slip for the document.

getEventItems()

Contains an EventItem element for each event to which an object should respond.

getFonts()

Contains a collection of Font elements

Example

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
diagram = new aspose.diagram.Diagram("RetrieveFontInfo.vsd");
fonts = diagram.getFonts();
for (var it = fonts.iterator(); it.hasNext();) {
font = it.next();
// Display information about the fonts
console.log(font.getName());
}

getHeaderFooter()

Contains elements for a document's header and footer.

getInterruptMonitor()

Gets and sets the interrupt monitor.

getKey()

Indicates whether the document has been modified outside of Visio. If present, Visio will fully test the contents of the file. Omit for files you create outside of Visio.

getMasters()

Collection Master objects.

getMetric()

Whether to use metric units in the drawing. Set this attribute to True (1) to use metric units; set it to False (0) to use English units. The value of the property is BOOL integer constant.

getPages()

Collection Page objects.

getRibbonX()

The Ribbon XML string that is passed to the document to customize the ribbon user interface.

getSolutionXMLs()

XML value.

Example

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
diagram = new aspose.diagram.Diagram("SolutionXML.vsdx");
// iterate through SolutionXML elements
for (it = diagram.getSolutionXMLs().iterator(); it.hasNext();) {
solutionXML = it.next();
// get name property
console.log(solutionXML.getName());
// get xml value
console.log(solutionXML.getXmlValue());
}

getStart()

Indicates whether the document has been modified outside of Visio. If present, Visio will fully test the contents of the file. Omit for files you create outside of Visio.

getStyleSheets()

Collection StyleSheet objects.

Example

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
diagram = new aspose.diagram.Diagram("ApplyCustomStyleSheets.vsd");
sourceShape = null;
// get page by name
page = diagram.getPages().getPage("Flow 1");
// Find the shape that you want to apply style to
for (it = page.getShapes().iterator(); it.hasNext();) {
shape = it.next();
if (shape.getName() == "Process") {
sourceShape = shape;
break;
}
}
customStyleSheet = null;
// Find the required style sheet
for (it = diagram.getStyleSheets().iterator(); it.hasNext();) {
styleSheet = it.next();
if (styleSheet.getName() == "Callout") {
customStyleSheet = styleSheet;
break;
}
}
if (sourceShape != null && customStyleSheet != null) {
// Apply text style
sourceShape.setTextStyle(customStyleSheet);
// Apply fill style
sourceShape.setFillStyle(customStyleSheet);
// Apply line style
sourceShape.setLineStyle(customStyleSheet);
}
diagram.save("out-ApplyCustomStyleSheets.vdx", aspose.diagram.SaveFileFormat.VDX);

getUnusedStyles()

Get unused Styles

getUserCustomUI()

The Ribbon XML string that is passed to the document to customize the Quick Access toolbar or the ribbon.

getValidation()

Stores information about diagram validation for the document.

getVbaProject()

Gets the VbaProjectVbaProject.

getVbProjectData()

Contains the Microsoft Visual Basic for Applications project data in MIME (Multipurpose Internet Mail Extensions) encoded format.

Example

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
diagram = new aspose.diagram.Diagram("Macro.vsdm");
// remove all macros
diagram.setVbProjectData(null);
// save the Visio diagram
diagram.save("out-RemoveMacros.vssm", aspose.diagram.SaveFileFormat.VSSM);

getVersion()

The version number of the Visio instance. Microsoft Visio 2010 = 14.

getWindows()

Contains the Window elements for a document.

Example

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
diagram = new aspose.diagram.Diagram("TextBoxes.vsdx");
// iterate through the window elements
for (it = diagram.getWindows().iterator(); it.hasNext();) {
window = it.next();
console.log("ID: " + window.getID());
console.log("Type: " + window.getWindowType());
console.log("Window height: " + window.getWindowHeight());
console.log("Window width: " + window.getWindowWidth());
console.log("Window state: " + window.getWindowState());
}

hasHiddenInfo()

Indicates whether this diagram has hidden information.

layout(options)

Lays out the shapes and/or reroutes the connectors for all pages of diagram.

Parameter

Name Type Optional Description

options

LayoutOptions

 

Using the

print(printerName)

Print the whole document to the specified printer,using the standard (no User Interface) print controller. If printerName is Null or empty will be used default printer.

Parameter

Name Type Optional Description

printerName

String

 

The name of the printer.Can be Null

print(printerName, options)

Print the whole document to the specified printer,using the standard (no User Interface) print controller. If printerName is Null or empty will be used default printer.

Parameters

Name Type Optional Description

printerName

String

 

The name of the printer.Can be Null

options

PrintSaveOptions

 

The print options.

print(printerName, documentName, options)

Prints the document,using the standard (no User Interface) print controller and a document name.

Parameters

Name Type Optional Description

printerName

String

 

The name of the printer.Can be Null

documentName

String

 

The document name to display (for example, in a print status dialog box or printer queue) while printing the document.

options

PrintSaveOptions

 

The print options.

print(printerName, documentName)

Prints the document,using the standard (no User Interface) print controller and a document name.

Example

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
diagram = new aspose.diagram.Diagram("Pages.vsdx");
// call the print method to print whole Diagram using the printer name
// and set document name in the print job
diagram.print("Microsoft Print to PDF", "Job name while printing with Aspose.Diagram");

Parameters

Name Type Optional Description

printerName

String

 

The name of the printer.Can be Null

documentName

String

 

The document name to display (for example, in a print status dialog box or printer queue) while printing the document.

removeHiddenInformation(item)

Remove unused information

Parameter

Name Type Optional Description

item

Number

 

RemoveHiddenInfoItem.

removeMacro()

Removes VBA/macro from this diagram.

save(filename, format)

Saves the diagram data to the file.

Parameters

Name Type Optional Description

filename

String

 

The file name.

format

Number

 

SaveFileFormat

save(stream, saveOptions)

Save the diagram to the stream.

Parameters

Name Type Optional Description

stream

OutputStream

 

The file stream.

saveOptions

SaveOptions

 

The save options.

save(filename, options)

Saves the document to a file using the specified save options.

Parameters

Name Type Optional Description

filename

String

 

The file name.

options

SaveOptions

 

SaveOptions

setBuildnum()

The build number of the Visio instance used to create the document.

setDocLangID()

The unique ID of the user-interface language the user has specified in Microsoft Office 2010 Language Preferences.

setEmailRoutingData()

Contains a MIME (Multipurpose Internet Mail Extensions) encoded MAPI e-mail routing slip for the document.

setFontDirs()

Indicates the Fonts folder path

Example

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
var fontDirs = ["C:\\MyFonts\\", "D:\\Misc\\Fonts\\"];
diagram = new aspose.diagram.Diagram("SpecifyFontLocation.vsdx");
// setting the custom font directories
diagram.setFontDirs(fontDirs);
// saving Visio diagram in PDF format
diagram.save("out-SpecifyFontLocation.pdf", aspose.diagram.SaveFileFormat.PDF);

setInterruptMonitor()

Gets and sets the interrupt monitor.

setKey()

Indicates whether the document has been modified outside of Visio. If present, Visio will fully test the contents of the file. Omit for files you create outside of Visio.

setMetric()

Whether to use metric units in the drawing. Set this attribute to True (1) to use metric units; set it to False (0) to use English units. The value of the property is BOOL integer constant.

setRibbonX()

The Ribbon XML string that is passed to the document to customize the ribbon user interface.

setStart()

Indicates whether the document has been modified outside of Visio. If present, Visio will fully test the contents of the file. Omit for files you create outside of Visio.

setUserCustomUI()

The Ribbon XML string that is passed to the document to customize the Quick Access toolbar or the ribbon.

setVbProjectData()

Contains the Microsoft Visual Basic for Applications project data in MIME (Multipurpose Internet Mail Extensions) encoded format.

Example

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
diagram = new aspose.diagram.Diagram("Macro.vsdm");
// remove all macros
diagram.setVbProjectData(null);
// save the Visio diagram
diagram.save("out-RemoveMacros.vssm", aspose.diagram.SaveFileFormat.VSSM);

setVersion()

The version number of the Visio instance. Microsoft Visio 2010 = 14.