asposediagram.api

Class Diagram

Root element of Visio objects hierarchy.

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(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
methodgetActivePage()
Specifies the active page
methodgetBuildnum()
method
           The build number of the Visio instance used to create the document.
methodgetColors()
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.
methodgetDataConnections()
Contains the DataConnection elements for the document.
methodgetDataRecordSets()
The collection of DataRecordset objects associated with a Document object.
methodgetDocLangID()
method
           The unique ID of the user-interface language the user has specified in Microsoft Office 2010 Language Preferences.
methodgetDocumentProps()
Contains document property elements such as the document's title, author, and so on.
methodgetDocumentSettings()
Contains elements that specify document settings.
methodgetDocumentSheet()
Specifies a document's ShapeSheet structure.
methodgetEmailRoutingData()
method
           Contains a MIME (Multipurpose Internet Mail Extensions) encoded MAPI e-mail routing slip for the document.
methodgetEventItems()
Contains an EventItem element for each event to which an object should respond.
voidsetFontDirs(value)
Indicates the Fonts folder path
methodgetFonts()
Contains a collection of Font elements
methodgetHeaderFooter()
Contains elements for a document's header and footer.
methodgetInterruptMonitor()
method
           Gets and sets the interrupt monitor.
methodgetKey()
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.
methodgetMasters()
Collection Master objects.
methodgetMetric()
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.
methodgetPages()
Collection Page objects.
methodgetRibbonX()
method
setRibbonX(value)
           The Ribbon XML string that is passed to the document to customize the ribbon user interface.
methodgetSolutionXMLs()
XML value.
methodgetStart()
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.
methodgetStyleSheets()
Collection StyleSheet objects.
methodgetUserCustomUI()
method
           The Ribbon XML string that is passed to the document to customize the Quick Access toolbar or the ribbon.
methodgetValidation()
Stores information about diagram validation for the document.
methodgetVbaProject()
Gets the VbaProjectVbaProject.
methodgetVbProjectData()
method
           Contains the Microsoft Visual Basic for Applications project data in MIME (Multipurpose Internet Mail Extensions) encoded format.
methodgetVersion()
method
setVersion(value)
           The version number of the Visio instance. Microsoft Visio 2010 = 14.
methodgetWindows()
Contains the Window elements for a document.
 
Method Summary
methodaddMaster(srcDiagram, masterName)
Adds master to diagram from source diagram by master's Name or NameU.
methodaddMaster(templateFilePath, masterID)
Adds master to diagram from template file by master's ID.
methodaddMaster(templateFilePath, masterName)
Adds master to diagram from template file by master's Name or NameU.
methodaddShape(newShape, masterName, pageNumber)
Adds shape created by master to specific page.
methodaddShape(pinX, pinY, width, height, masterName, pageNumber)
Adds shape created by master on page with defined PinX,PinY,Width and Height.
methodaddShape(pinX, pinY, masterName, pageNumber)
Adds shape created by master on page with defined PinX and PinY.
methodcombine(secondDiagram)
Combines another Diagram object.
methodcopyTheme(source)
Copies Theme from a source Diagram.
methoddispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
methodgetDefaultFontDir()
Get the Default Fonts folder path
methodgetUnusedStyles()
Get unused Styles
methodhasHiddenInfo()
Indicates whether this diagram has hidden information.
methodprint(printerName)
Print the whole document to the specified printer,using the standard (no User Interface) print controller.
methodprint(printerName, documentName)
Prints the document,using the standard (no User Interface) print controller and a document name.
methodremoveHiddenInformation(item)
Remove unused information
methodremoveMacro()
Removes VBA/macro from this diagram.
methodsave(filename, format)
Saves the diagram data to the file.
 

    • Constructor Detail

      • Diagram

        Diagram()
      • Diagram

        Diagram(filename)
        Public class constructor, loads the diagram from the file.
        Parameters:
        filename: String - The file name.
      • Diagram

        Diagram(filename, format)
        Public class constructor, loads the diagram from the file using predefined format.
        Parameters:
        filename: String - The file name.
        format: int - A LoadFileFormat value. The file format.
      • Diagram

        Diagram(filename, options)
        Public class constructor, loads the diagram from the file using predefined load file options.
        Parameters:
        filename: String - The file name.
        options: LoadOptions - The data LoadOptions.
    • Property Getters/Setters Detail

      • getStart/setStart : long 

        long getStart() / 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.
      • setFontDirs : String[] 

        setFontDirs(value)
        
        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);
      • getKey/setKey : String 

        String getKey() / 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.
      • getMetric/setMetric : int 

        int getMetric() / 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.
      • getBuildnum/setBuildnum : long 

        long getBuildnum() / setBuildnum(value)
        
        The build number of the Visio instance used to create the document.
      • getVersion/setVersion : String 

        String getVersion() / setVersion(value)
        
        The version number of the Visio instance. Microsoft Visio 2010 = 14.
      • getDocLangID/setDocLangID : int 

        int getDocLangID() / setDocLangID(value)
        
        The unique ID of the user-interface language the user has specified in Microsoft Office 2010 Language Preferences.
      • getStyleSheets : StyleSheetCollection 

        StyleSheetCollection 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);
      • getDocumentProps : DocumentProperties 

        DocumentProperties 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());
      • getColors : ColorEntryCollection 

        ColorEntryCollection 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.
      • getFonts : FontCollection 

        FontCollection 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());
        }
      • getActivePage : Page 

        Page getActivePage()
        
        Specifies the active page
      • getWindows : WindowCollection 

        WindowCollection 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());
        }
      • getVbProjectData/setVbProjectData : byte[] 

        byte[] getVbProjectData() / setVbProjectData(value)
        
        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);
      • getEmailRoutingData/setEmailRoutingData : byte[] 

        byte[] getEmailRoutingData() / setEmailRoutingData(value)
        
        Contains a MIME (Multipurpose Internet Mail Extensions) encoded MAPI e-mail routing slip for the document.
      • getRibbonX/setRibbonX : String 

        String getRibbonX() / setRibbonX(value)
        
        The Ribbon XML string that is passed to the document to customize the ribbon user interface.
      • getUserCustomUI/setUserCustomUI : String 

        String getUserCustomUI() / setUserCustomUI(value)
        
        The Ribbon XML string that is passed to the document to customize the Quick Access toolbar or the ribbon.
      • getValidation : Validation 

        Validation getValidation()
        
        Stores information about diagram validation for the document.
      • getSolutionXMLs : SolutionXMLCollection 

        SolutionXMLCollection 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());
        }
    • Method Detail

      • save

         save(filename, format)
        Saves the diagram data to the file.
        Parameters:
        filename: String - The file name.
        format: int - A SaveFileFormat value. SaveFileFormat save file format.
      • dispose

         dispose()
        Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
      • copyTheme

         copyTheme(source)
        Copies Theme from a source Diagram.
        Parameters:
        source: Diagram - source diagram.
      • combine

         combine(secondDiagram)
        Combines another Diagram object.
        Parameters:
        secondDiagram: Diagram - Another Diagram object.
      • addMaster

        int addMaster(srcDiagram, masterName)
        Adds master to diagram from source diagram by master's Name or NameU.
        Parameters:
        srcDiagram: Diagram - source diagram.
        masterName: String - Master's Name or NameU.
        Returns:
        The unique ID of the master within masters collection in this diagram.

        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

        int addMaster(templateFilePath, masterName)
        Adds master to diagram from template file by master's Name or NameU.
        Parameters:
        templateFilePath: String - Path to template file(can be vdx, vst or vsd format).
        masterName: String - Master's Name or NameU.
        Returns:
        The unique ID of the master within masters collection in this diagram.

        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

        int addMaster(templateFilePath, masterID)
        Adds master to diagram from template file by master's ID.
        Parameters:
        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.
        Returns:
        The unique ID of the master within masters collection in this diagram.

        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

        boolean hasHiddenInfo()
        Indicates whether this diagram has hidden information.
      • removeHiddenInformation

         removeHiddenInformation(item)
        Remove unused information
        Parameters:
        item: int - RemoveHiddenInfoItem.
      • addShape

        long addShape(newShape, masterName, pageNumber)
        Adds shape created by master to specific page.
        Parameters:
        newShape: Shape - New shape objectShape.
        masterName: String - Master's name.
        pageNumber: int - Index of page.
        Returns:
        The unique ID of the shape within shapes collection on the specified page.
      • addShape

        long addShape(pinX, pinY, masterName, pageNumber)
        Adds shape created by master on page with defined PinX and PinY.
        Parameters:
        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.
        Returns:
        The unique ID of the shape within shapes collection on the specified 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

        long addShape(pinX, pinY, width, height, masterName, pageNumber)
        Adds shape created by master on page with defined PinX,PinY,Width and Height.
        Parameters:
        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.
        Returns:
        The unique ID of the shape within shapes collection on the specified 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

         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.
        Parameters:
        printerName: String - The name of the printer.Can be Null
      • print

         print(printerName, documentName)
        Prints the document,using the standard (no User Interface) print controller and a document name.
        Parameters:
        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.

        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

        ArrayList 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());
      • removeMacro

         removeMacro()
        Removes VBA/macro from this diagram.