How to set Shape Title using .NET

Hi,
Looking at https://docs.microsoft.com/en-us/previous-versions/office/developer/office-2010/cc797752(v=office.14)

There are two optional attributes on shape object in word.

  • spid (Optional String)
  • spt (Optional Number)

Is there any way to set these attribute throw aspose.words Java API?

Can we use Shape.setShapeAttr (int key,Object value) API for this? If so, what is the key value to be passed?

-Satya

Hi Satya,

Thanks for your inquiry. Aspose.Words does not provide API for spid and spt. Aspose.Words supports the Shape.AlternativeText which get or set the alternative text (description) of shape.

In your case, I suggest you please use Shape.AlternativeText property. Hope this helps you. See the attached image for the detail of alternative text (description) of shape.

Document doc = new Document(MyDir + "in.docx");

Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 0, true);

shape.setAlternativeText("Shape 1");

doc.save(MyDir + “Out.docx”);

Satya D:

Can we use Shape.setShapeAttr (int key,Object value) API for this? If so, what is the key value to be passed?

This method is used for internal use of Aspose.Words. This is not public method. Please do not use this method.

@SatyaD

Starting from Aspose.Words 16.3, you can set the shape title and description of Shape. Following code example shows how to set title of shape object.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Create test shape
Shape shape = new Shape(doc, ShapeType.CUBE);
shape.setWidth(431.5);
shape.setHeight(346.35);
shape.setTitle("Alt Text Title");

builder.insertNode(shape);