aspose.diagram
Class Txt

Text of the shape

Example:

var aspose = aspose || {};
aspose.diagram = require("aspose.diagram");

diagram = new aspose.diagram.Diagram("FindReplaceText.vsdx");

// Prepare a collection old and new text
replacements = {
    "[[CompanyName]]": "Research Society",
    "[[EmployeeName]]": "James Bond",
    "[[SubjectTitle]]": "The affect of the internet on social behavior in the industrialize world",
    "[[SubmissionDate]]": new Date().toDateString(),
    "[[AmountReq]]": "$100,000"}

// Iterate through the shapes of a page
for (it = diagram.getPages().getPage("Page-1").getShapes().iterator(); it.hasNext();) {
    shape = it.next();
    for (key in replacements) {
        for (it_txt = shape.getText().getValue().iterator(); it_txt.hasNext();) {
            txt = it_txt.next();

            var strFun = txt.constructor.toString();
            var className = strFun.substr(0, strFun.indexOf('('));
            className = className.replace('function', '');
            className = className.replace(/(^\s*)|(\s*$)/ig, '');
            if (className == "nodeJava_com_aspose_diagram_Txt") {
                // find and replace text of a shape
                if (txt.getText().indexOf(key) != -1) {
                    txt.setText(replacements[key]);
                }
            }
        }
    }
}

diagram.save("out-FindAndReplaceShapeText.vsdx", aspose.diagram.SaveFileFormat.VSDX);

Constructor Summary
Txt(value)
           Constructor
 
Property Getters/Setters Summary
functiongetText()
functionsetText(value)
           Contains the text of a shape.
functiongetValue()
           Value
 

Constructor Detail

Txt

function Txt(value)
Constructor
Parameters:
value: String - Text of the shape.

Property Getters/Setters Detail

getValue : String 

function getValue()
Value

getText/setText : String 

function getText() / function setText(value)
Contains the text of a shape.

See Also:
          Aspose.Cells Documentation - the home page for the Aspose.Cellss Product Documentation.
          Aspose.Cells Support Forum - our preferred method of support.