Created
May 12, 2020 15:09
-
-
Save aspose-com-gists/d4adedf6fd5115e7022c95bacaa806ce to your computer and use it in GitHub Desktop.
Create Visio Diagrams in Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var aspose = aspose || {}; | |
aspose.diagram = require("aspose.diagram"); | |
var diagram = new aspose.diagram.Diagram(); | |
page = diagram.getPages().getPage(0); | |
// Get shape by ID | |
shape = page.getShapes().getShape(2); | |
// Initialize Hyperlink object | |
hyperlink = new aspose.diagram.Hyperlink(); | |
// Set address value | |
hyperlink.getAddress().setValue("http://www.google.com/"); | |
// Set sub address value | |
hyperlink.getSubAddress().setValue("Sub address here"); | |
// Set description value | |
hyperlink.getDescription().setValue("Description here"); | |
// Set name | |
hyperlink.setName("MyHyperLink"); | |
// Add hyperlink to the shape | |
shape.getHyperlinks().add(hyperlink); | |
diagram.save("output.vsdx", aspose.diagram.SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var aspose = aspose || {}; | |
aspose.diagram = require("aspose.diagram"); | |
var diagram = new aspose.diagram.Diagram(); | |
// Load stencil to a stream | |
templateFileName = "NetApp-FAS-series.vss"; | |
// Add master with stencil file path and master id | |
masterName = "FAS80xx rear empty"; | |
diagram.addMaster(templateFileName, 2); | |
// Or add master with stencil file path and master name | |
diagram.addMaster(templateFileName, masterName); | |
// Or add master to diagram from source diagram | |
src = new aspose.diagram.Diagram(templateFileName); | |
diagram.addMaster(src, masterName); | |
// Add shape with defined PinX and PinY. | |
diagram.addShape(2.0, 2.0, masterName, 0); | |
diagram.addShape(6.0, 6.0, masterName, 0); | |
// Add shape with defined PinX,PinY,Width and Height. | |
diagram.addShape(7.0, 3.0, 1.5, 1.5, masterName, 0); | |
diagram.save("output.vsdx", aspose.diagram.SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var aspose = aspose || {}; | |
aspose.diagram = require("aspose.diagram"); | |
var diagram = new aspose.diagram.Diagram(); | |
// it calculates max page id | |
max = 0; | |
if (diagram.getPages().getCount() != 0) | |
max = diagram.getPages().get(0).getID(); | |
for ( i = 1; i < diagram.getPages().getCount(); i++) | |
{ | |
if (max < diagram.getPages().get(i).getID()) | |
max = diagram.getPages().get(i).getID(); | |
} | |
// Initialize a new page object | |
newPage = new aspose.diagram.Page(); | |
// Set name | |
newPage.setName("new page"); | |
// Set page ID | |
newPage.setID(max + 1); | |
// Or try the Page constructor | |
// Page newPage = new Page(MaxPageId + 1); | |
// Add a new blank page | |
diagram.getPages().add(newPage); | |
diagram.save("output.vsdx", aspose.diagram.SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var aspose = aspose || {}; | |
aspose.diagram = require("aspose.diagram"); | |
var diagram = new aspose.diagram.Diagram("output.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("Basic Shapes.vss", masterName); | |
// Page indexing starts from 0 | |
PageIndex = 2; | |
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(TypeValue.SHAPE); | |
rectangle.getText().getValue().add(new 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"); | |
diagram.save("output.vsdx", aspose.diagram.SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var aspose = aspose || {}; | |
aspose.diagram = require("aspose.diagram"); | |
var diagram = new aspose.diagram.Diagram(); | |
// Set parameters | |
PinX = 1, PinY = 1, Width = 1, Height = 1; | |
text = "Test text"; | |
// Add text to a Visio page | |
diagram.getPages().getPage(0).addText(PinX, PinY, Width, Height, text); | |
diagram.save("output.vsdx", aspose.diagram.SaveFileFormat.VSDX); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var aspose = aspose || {}; | |
aspose.diagram = require("aspose.diagram"); | |
var diagram = new aspose.diagram.Diagram(); | |
diagram.save("output.vsdx", aspose.diagram.SaveFileFormat.VSDX); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment