Example:
The following example creates a diagram from a file and saves it to another file.
//Use Aspose.Diagram for Node.js via Java
var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
var diagram = new aspose.diagram.Diagram("example.vsdx");
diagram.save("output.vsdx", aspose.diagram.SaveFileFormat.VSDX);
| Constructor Summary |
|---|
Diagram()
|
Diagram(filename)
Public class constructor, loads the diagram from the file. |
Diagram(filename, format)
Public class constructor, loads the diagram from the file using predefined format. |
Diagram(filename, options)
Public class constructor, loads the diagram from the file using predefined load file options. |
| Property Getters/Setters Summary | ||
|---|---|---|
method | getActivePage() | |
Specifies the active page
|
||
method | getBuildnum() | |
method | setBuildnum(value) | |
| The build number of the Visio instance used to create the document. | ||
method | 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.
|
||
method | getDataConnections() | |
Contains the DataConnection elements for the document.
|
||
method | getDataRecordSets() | |
The collection of DataRecordset objects associated with a Document object.
|
||
method | getDocLangID() | |
method | setDocLangID(value) | |
| The unique ID of the user-interface language the user has specified in Microsoft Office 2010 Language Preferences. | ||
method | getDocumentProps() | |
Contains document property elements such as the document's title, author, and so on.
|
||
method | getDocumentSettings() | |
Contains elements that specify document settings.
|
||
method | getDocumentSheet() | |
Specifies a document's ShapeSheet structure.
|
||
method | getEmailRoutingData() | |
method | setEmailRoutingData(value) | |
| Contains a MIME (Multipurpose Internet Mail Extensions) encoded MAPI e-mail routing slip for the document. | ||
method | getEventItems() | |
Contains an EventItem element for each event to which an object should respond.
|
||
void | setFontDirs(value) | |
Indicates the Fonts folder path
|
||
method | getFonts() | |
Contains a collection of Font elements
|
||
method | getHeaderFooter() | |
Contains elements for a document's header and footer.
|
||
method | getInterruptMonitor() | |
method | setInterruptMonitor(value) | |
| Gets and sets the interrupt monitor. | ||
method | getKey() | |
method | setKey(value) | |
| 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. | ||
method | getMasters() | |
Collection Master objects.
|
||
method | getMetric() | |
method | setMetric(value) | |
| 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. | ||
method | getPages() | |
Collection Page objects.
|
||
method | getRibbonX() | |
method | setRibbonX(value) | |
| The Ribbon XML string that is passed to the document to customize the ribbon user interface. | ||
method | getSolutionXMLs() | |
XML value.
|
||
method | getStart() | |
method | setStart(value) | |
| 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. | ||
method | getStyleSheets() | |
Collection StyleSheet objects.
|
||
method | getUserCustomUI() | |
method | setUserCustomUI(value) | |
| The Ribbon XML string that is passed to the document to customize the Quick Access toolbar or the ribbon. | ||
method | getValidation() | |
Stores information about diagram validation for the document.
|
||
method | getVbaProject() | |
Gets the VbaProject |
||
method | getVbProjectData() | |
method | setVbProjectData(value) | |
| Contains the Microsoft Visual Basic for Applications project data in MIME (Multipurpose Internet Mail Extensions) encoded format. | ||
method | getVersion() | |
method | setVersion(value) | |
| The version number of the Visio instance. Microsoft Visio 2010 = 14. | ||
method | getWindows() | |
Contains the Window elements for a document.
|
||
| Method Summary | ||
|---|---|---|
method | addMaster(srcDiagram, masterName) | |
Adds master to diagram from source diagram by master's Name or NameU.
|
||
method | addMaster(templateFilePath, masterID) | |
Adds master to diagram from template file by master's ID.
|
||
method | addMaster(templateFilePath, masterName) | |
Adds master to diagram from template file by master's Name or NameU.
|
||
method | addShape(newShape, masterName, pageNumber) | |
Adds shape created by master to specific page.
|
||
method | addShape(pinX, pinY, width, height, masterName, pageNumber) | |
Adds shape created by master on page with defined PinX,PinY,Width and Height.
|
||
method | addShape(pinX, pinY, masterName, pageNumber) | |
Adds shape created by master on page with defined PinX and PinY.
|
||
method | combine(secondDiagram) | |
Combines another Diagram object.
|
||
method | copyTheme(source) | |
Copies Theme from a source Diagram.
|
||
method | dispose() | |
Performs application-defined tasks associated with freeing, releasing, or
resetting unmanaged resources.
|
||
method | getDefaultFontDir() | |
Get the Default Fonts folder path
|
||
method | getUnusedStyles() | |
Get unused Styles
|
||
method | hasHiddenInfo() | |
Indicates whether this diagram has hidden information.
|
||
method | print(printerName) | |
Print the whole document to the specified printer,using the standard (no User Interface) print controller.
|
||
method | print(printerName, documentName) | |
Prints the document,using the standard (no User Interface) print controller and a document name.
|
||
method | removeHiddenInformation(item) | |
Remove unused information
|
||
method | removeMacro() | |
Removes VBA/macro from this diagram.
|
||
method | save(filename, format) | |
Saves the diagram data to the file.
|
||
Diagram()
Diagram(filename)
filename: String - The file name.Diagram(filename, format)
filename: String - The file name.format: int - A Diagram(filename, options)
filename: String - The file name.options: LoadOptions - The data long getStart() / setStart(value)
setFontDirs(value)
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);String getKey() / setKey(value)
int getMetric() / setMetric(value)
long getBuildnum() / setBuildnum(value)
String getVersion() / setVersion(value)
int getDocLangID() / setDocLangID(value)
StyleSheetCollection getStyleSheets()
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);MasterCollection getMasters()
PageCollection getPages()
DocumentProperties getDocumentProps()
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());DocumentSettings getDocumentSettings()
ColorEntryCollection getColors()
FontCollection getFonts()
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());
}DocumentSheet getDocumentSheet()
WindowCollection getWindows()
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());
}EventItemCollection getEventItems()
HeaderFooter getHeaderFooter()
byte[] getVbProjectData() / setVbProjectData(value)
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);byte[] getEmailRoutingData() / setEmailRoutingData(value)
DataConnectionCollection getDataConnections()
DataRecordSetCollection getDataRecordSets()
String getRibbonX() / setRibbonX(value)
String getUserCustomUI() / setUserCustomUI(value)
Validation getValidation()
SolutionXMLCollection getSolutionXMLs()
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());
}VbaProject getVbaProject()
AbstractInterruptMonitor getInterruptMonitor() / setInterruptMonitor(value)
save(filename, format)
filename: String - The file name.format: int - A dispose()
copyTheme(source)
source: Diagram - source diagram.combine(secondDiagram)
secondDiagram: Diagram - Another Diagram object.int addMaster(srcDiagram, masterName)
srcDiagram: Diagram - source diagram.masterName: String - 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);int addMaster(templateFilePath, masterName)
templateFilePath: String - Path to template file(can be vdx, vst or vsd format).masterName: String - 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);int addMaster(templateFilePath, masterID)
templateFilePath: String - Path to template file(can be vdx, vst or vsd format).masterID: int - The unique ID of the master within masters collection in template.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);boolean hasHiddenInfo()
removeHiddenInformation(item)
item: int - RemoveHiddenInfoItem.StyleSheetCollection getUnusedStyles()
long addShape(newShape, masterName, pageNumber)
newShape: Shape - New shape objectmasterName: String - Master's name.pageNumber: int - Index of page.long addShape(pinX, pinY, masterName, pageNumber)
pinX: float - Specifies the x-coordinate of the shape's pin (center of rotation) in relation to the page.pinY: float - Specifies the y-coordinate of the shape's pin (center of rotation) in relation to the page.masterName: String - Master's name.pageNumber: int - Index of page.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);long addShape(pinX, pinY, width, height, masterName, pageNumber)
pinX: float - Specifies the x-coordinate of the shape's pin (center of rotation) in relation to the page.pinY: float - Specifies the y-coordinate of the shape's pin (center of rotation) in relation to the page.width: float - Specifies the width of the shape in inches.height: float - Specifies the height of the shape in inches.masterName: String - Master's name.pageNumber: int - Index of page.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);print(printerName)
printerName: String - The name of the printer.Can be Nullprint(printerName, documentName)
printerName: String - The name of the printer.Can be NulldocumentName: String - The document name to display (for example, in a print status dialog box or printer queue) while printing the document. 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");ArrayList getDefaultFontDir()
Example:
var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");
diagram = new aspose.diagram.Diagram("RetrieveFontInfo.vsd");
console.log(diagram.getDefaultFontDir());removeMacro()