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 |
Diagram(filename, format)
Public |
Diagram(filename, options)
Public |
Property Getters/Setters Summary | ||
---|---|---|
function | getBuildnum() | |
function | setBuildnum(value) | |
The build number of the Visio instance used to create the document. | ||
function | 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. | ||
function | getDataConnections() | |
Contains the DataConnection elements for the document. | ||
function | getDataRecordSets() | |
The collection of DataRecordset objects associated with a Document object. | ||
function | getDocLangID() | |
function | setDocLangID(value) | |
The unique ID of the user-interface language the user has specified in Microsoft Office 2010 Language Preferences. | ||
function | getDocumentProps() | |
Contains document property elements such as the document's title, author, and so on. | ||
function | getDocumentSettings() | |
Contains elements that specify document settings. | ||
function | getDocumentSheet() | |
Specifies a document's ShapeSheet structure. | ||
function | getEmailRoutingData() | |
function | setEmailRoutingData(value) | |
Contains a MIME (Multipurpose Internet Mail Extensions) encoded MAPI e-mail routing slip for the document. | ||
function | getEventItems() | |
Contains an EventItem element for each event to which an object should respond. | ||
function | setFontDirs(value) | |
Indicates the Fonts folder path | ||
function | getFonts() | |
Contains a collection of Font elements | ||
function | getHeaderFooter() | |
Contains elements for a document's header and footer. | ||
function | getKey() | |
function | 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. | ||
function | getMasters() | |
Collection Master objects. | ||
function | getMetric() | |
function | 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. | ||
function | getPages() | |
Collection Page objects. | ||
function | getRibbonX() | |
function | setRibbonX(value) | |
The Ribbon XML string that is passed to the document to customize the ribbon user interface. | ||
function | getSolutionXMLs() | |
XML value. | ||
function | getStart() | |
function | 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. | ||
function | getStyleSheets() | |
Collection StyleSheet objects. | ||
function | getUserCustomUI() | |
function | setUserCustomUI(value) | |
The Ribbon XML string that is passed to the document to customize the Quick Access toolbar or the ribbon. | ||
function | getValidation() | |
Stores information about diagram validation for the document. | ||
function | getVbaProject() | |
Gets the VbaProject |
||
function | getVbProjectData() | |
function | setVbProjectData(value) | |
Contains the Microsoft Visual Basic for Applications project data in MIME (Multipurpose Internet Mail Extensions) encoded format. | ||
function | getVersion() | |
function | setVersion(value) | |
The version number of the Visio instance. Microsoft Visio 2010 = 14. | ||
function | getWindows() | |
Contains the Window elements for a document. |
Method Summary | ||
---|---|---|
function | addMaster(srcDiagram, masterName) | |
Adds master to diagram from source diagram by master's Name or NameU. | ||
function | addMaster(templateFilePath, masterID) | |
Adds master to diagram from template file by master's ID. | ||
function | addMaster(templateFilePath, masterName) | |
Adds master to diagram from template file by master's Name or NameU. | ||
function | addShape(newShape, masterName, pageNumber) | |
Adds shape created by master to specific page. | ||
function | addShape(pinX, pinY, width, height, masterName, pageNumber) | |
Adds shape created by master on page with defined PinX,PinY,Width and Height. | ||
function | addShape(pinX, pinY, masterName, pageNumber) | |
Adds shape created by master on page with defined PinX and PinY. | ||
function | combine(secondDiagram) | |
Combines another Diagram object. | ||
function | copyTheme(source) | |
Copies Theme from a source Diagram. | ||
static function | createDiagramFromStream(stream, callback) | |
Public class constructor, loads the diagram from the stream. | ||
static function | createDiagramFromStream(stream, options, callback) | |
Public class constructor, loads the diagram from the file using predefined load file options. | ||
static function | createDiagramFromStream(stream, format, callback) | |
Public class constructor, loads the diagram from the stream using predefined format. | ||
function | dispose() | |
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. | ||
function | getDefaultFontDir() | |
Get the Default Fonts folder path | ||
function | getUnusedStyles() | |
Get unused Styles | ||
function | hasHiddenInfo() | |
Indicates whether this diagram has hidden infomation. | ||
function | layout(options) | |
Lays out the shapes and/or reroutes the connectors for all pages of diagram. | ||
function | print(printerName) | |
Print the whole document to the specified printer,using the standard (no User Interface) print controller. | ||
function | print(printerName, documentName) | |
Prints the document,using the standard (no User Interface) print controller and a document name. | ||
function | removeHiddenInformation(item) | |
Remove unused information | ||
function | removeMacro() | |
Removes VBA/macro from this diagram. | ||
static function | save(diagram, stream, saveFormat) | |
Saves the diagram data to the stream. | ||
static function | save(diagram, stream, options) | |
Saves the diagram to a file using the specified save options. | ||
function | save(filename, options) | |
Saves the document to a file using the specified save options. | ||
function | save(filename, format) | |
Saves the diagram data to the file. |
Constructor Detail |
---|
function Diagram()
function Diagram(filename)
filename: String
- The file name.function Diagram(filename, format)
filename: String
- The file name.format: Number
- A function Diagram(filename, options)
filename: String
- The file name.options: LoadOptions
- The data Property Getters/Setters Detail |
---|
getStart/setStart : long | |
function getStart() / function setStart(value) |
setFontDirs : String[] | |
function 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);
getKey/setKey : String | |
function getKey() / function setKey(value) |
getMetric/setMetric : Number | |
function getMetric() / function setMetric(value) |
getBuildnum/setBuildnum : long | |
function getBuildnum() / function setBuildnum(value) |
getVersion/setVersion : String | |
function getVersion() / function setVersion(value) |
getDocLangID/setDocLangID : Number | |
function getDocLangID() / function setDocLangID(value) |
getStyleSheets : StyleSheetCollection | |
function 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);
getMasters : MasterCollection | |
function getMasters() |
getPages : PageCollection | |
function getPages() |
getDocumentProps : DocumentProperties | |
function 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());
getDocumentSettings : DocumentSettings | |
function getDocumentSettings() |
getColors : ColorEntryCollection | |
function getColors() |
getFonts : FontCollection | |
function 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()); }
getDocumentSheet : DocumentSheet | |
function getDocumentSheet() |
getWindows : WindowCollection | |
function 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()); }
getEventItems : EventItemCollection | |
function getEventItems() |
getHeaderFooter : HeaderFooter | |
function getHeaderFooter() |
getVbProjectData/setVbProjectData : byte[] | |
function getVbProjectData() / function 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);
getEmailRoutingData/setEmailRoutingData : byte[] | |
function getEmailRoutingData() / function setEmailRoutingData(value) |
getDataConnections : DataConnectionCollection | |
function getDataConnections() |
getDataRecordSets : DataRecordSetCollection | |
function getDataRecordSets() |
getRibbonX/setRibbonX : String | |
function getRibbonX() / function setRibbonX(value) |
getUserCustomUI/setUserCustomUI : String | |
function getUserCustomUI() / function setUserCustomUI(value) |
getValidation : Validation | |
function getValidation() |
getSolutionXMLs : SolutionXMLCollection | |
function 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()); }
getVbaProject : VbaProject | |
function getVbaProject() |
Method Detail |
---|
save | |
function save(filename, format) |
filename: String
- The file name.format: Number
- A save | |
function save(filename, options) |
filename: String
- The file name.options: SaveOptions
- dispose | |
function dispose() |
copyTheme | |
function copyTheme(source) |
source: Diagram
- source diagram.combine | |
function combine(secondDiagram) |
secondDiagram: Diagram
- Another Diagram object.layout | |
function layout(options) |
options: LayoutOptions
- Using the addMaster | |
function 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);
addMaster | |
function 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);
addMaster | |
function addMaster(templateFilePath, masterID) |
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.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);
hasHiddenInfo | |
function hasHiddenInfo() |
removeHiddenInformation | |
function removeHiddenInformation(item) |
item: Number
- RemoveHiddenInfoItem.getUnusedStyles | |
function getUnusedStyles() |
addShape | |
function addShape(newShape, masterName, pageNumber) |
newShape: Shape
- New shape objectmasterName: String
- Master's name.pageNumber: Number
- Index of page.addShape | |
function addShape(pinX, pinY, masterName, pageNumber) |
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.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);
addShape | |
function addShape(pinX, pinY, width, height, masterName, pageNumber) |
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.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);
function print(printerName) |
printerName: String
- The name of the printer.Can be Nullfunction print(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");
getDefaultFontDir | |
function getDefaultFontDir() |
Example:
var aspose = aspose || {}; aspose.diagram = require("aspose.diagram"); diagram = new aspose.diagram.Diagram("RetrieveFontInfo.vsd"); console.log(diagram.getDefaultFontDir());
removeMacro | |
function removeMacro() |
createDiagramFromStream | |
static function createDiagramFromStream(stream, callback) |
stream: ReadableStream
- The data streamcallback: Callback
- The callback functionExample:
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); });
createDiagramFromStream | |
static function createDiagramFromStream(stream, format, callback) |
stream: ReadableStream
- The data streamformat: Number
- A callback: Callback
- The callback functionExample:
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); });
createDiagramFromStream | |
static function createDiagramFromStream(stream, options, callback) |
stream: ReadableStream
- The data streamoptions: LoadOptions
- The data callback: Callback
- The callback functionExample:
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); });
save | |
static function save(diagram, stream, saveFormat) |
diagram: Diagram
- The diagram object to savestream: WritableStream
- The streamsaveFormat: Number
- A 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);
save | |
static function save(diagram, stream, options) |
diagram: Diagram
- The diagram object to savestream: WritableStream
- The streamoptions: SaveOptions
- 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);