new Txt(value)

Constructor

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);

Parameter

Name Type Optional Description

value

 

 

Text of the shape.

Methods

getText()

Contains the text of a shape.

getValue()

Value

setText()

Contains the text of a shape.