How to get and set Shape Title using Java

Hi. I’m new, I have been developing with the product for a few weeks and just purchased Aspose Total yesterday.



So, I updated my libraries to the latest version (14.12.0) and my code broke.



See attached Snippets.docx file.



Consider the following simple code:

Node shapes[] =snippetDoc.getChildNodes(NodeType.SHAPE, true).toArray();

logger.info(“Found {} nodes in snippets file”,shapes.length);



Results under 14.12.0: Found 0 nodes in snippets file

Results under 14.8.0: Found 4 nodes in snippets file



What’s weird right?

@brian-7

Thanks for your inquiry. Your document contains DrawingML nodes instead of Shape nodes. DrawingML class represents a DrawingML shape, picture, chart or diagram in a document.

Please change the NodeType as DRAWING_ML as shown below in your code to get the required output.

Node shapes[] = snippetDoc.getChildNodes(NodeType.DRAWING_ML, true).toArray();

Please let us know if you have any more queries.

Thanks for the quick response.


So the big issue was that nodes that previously were parsed as Shapes are now parsed as DrawingML nodes. This has happened since a few versions ago when DrawingML got promoted from an inline node to a CompositeNode node.


The related trick though, is that in a Shape, the AlternativeText title was retrieved from getAlternativeText(), in DrawingML, only the AlternativeText description is retrieved.
To fix my system, I had to migrate all my Textbox labels from the Alternative Text Title field to the Alternative Text Description field.


I can see now that the DrawingML promotion is mentioned in the public API changelog. In future I will be sure to read that carefully before upgrading.





Hi Brian,

Thanks for your inquiry. There was an issue in older version of Aspose.Words which has been fixed in latest version of Aspose.Words v14.12.0. Your document contains DrawingML nodes instead of Shape nodes. Please check the document.xml of your document. See the attached image for first DrawingML detail.

Unfortunately, Aspose.Words does not support the Alt Text title property of DrawingML. Aspose.Words supports the DrawingML.AlternativeText which get or set the alternative text (description).

However, we had already logged this feature request as WORDSNET-8122 in our issue tracking system. You will be notified via this forum thread once this feature is available. We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-8122) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(18)

The issues you have found earlier (filed as WORDSNET-8122) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(1)
Hi Brian,

Thanks for your inquiry. We removed the DrawingML from our APIs in Aspose.Words 15.2.0. So, the issue WORDSNET-8122 (Support of Alt Text Title property in DrawingML) was closed. Please read about public API changes in Aspose.Words 15.2.0 from following link.

We logged separate feature request as WORDSNET-12918 to get/set Alt Text Title property of Shape. You will be notified via this forum thread once this feature is available. We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-12918) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(2)

@brian-7

Starting from Aspose.Words 16.3, you can set and get the title of shape using Shape.Title property. 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);