I have another issue with connectors in a very simple configuration:
Place two rectangles, connect them with a straight connector and add some text to the connector.
The text is placed either on the left side of the connector or completely outside of the connector – depend on the order of shapes that it connects to.
When doing the same work from Visio – the text is centered.
See attached – example with a source code and stencil.
I will appreciate a workaround / a stencil with a fixed connector.
Thank you for contacting support. Please note, there is a “Controls” tab under each shape sheet. Its X and Y properties allow to adjust shape’s text position. You can formulate horizontal properties of the connectors before saving into the VDX file format by using Aspose.Diagram API as follows:
[Java]
// set text position
connector1.getControls().get(0).getX().getUfe().setF("(GUARD(EndX-BeginX)/2)");
connector2.getControls().get(0).getX().getUfe().setF("(GUARD(EndX-BeginX)/2)");
// save Visio diagram
diagram.save(“c:\MyOutput1.vdx”, options);
Thank you for the inquiry. For the diagonal connector, we need to formulate both horizontal and vertical properties. Please modify your sample code as follows:
[Java]
// set text position
connector1.getControls().get(0).getX().getUfe().setF(“GUARD(Width<em>0.5)");
connector1.getControls().get(0).getY().getUfe().setF("GUARD(Height</em>0.5)”);
connector2.getControls().get(0).getX().getUfe().setF(“GUARD(Width<em>0.5)");
connector2.getControls().get(0).getY().getUfe().setF("GUARD(Height</em>0.5)”);
// save Visio diagram
diagram.save(“c:\MyOutput1.vdx”, options);
Please let us know in case of any further assistance or questions.
Thank you for the details. Please note, in the above sample code, we’re calculating the shape’s text position by taking half of its width and height. Furthermore, the GUARD method prevents unexpected changes to the shape’s appearance. Please refer to the following MSDN help topic: GUARD Function
tamirl1:
I really wish there was more documentation for the code with more usage examples.
Well, it is our common practice to add more help topics in the Aspose APIs Wiki docs. We keep adding help topics from time to time. We have noted your feedback and also planned to review the above use case perspective.
You’re right because it concatenates an id with the keyword phrase using AND operator. However, when we removed operator and id from the text box and again clicked on the search button, it works perfectly. So as a workaround, please use this approach. We have forward this issue to our Web team (ticket id: MARKETING-14445). They will fix it soon. We’re sorry for the inconvenience caused.
Thank you for posting here. Please provide us your source Visio diagram along with the complete sample code. We’ll investigate and reply you appropriately.
Attached is a Zip file of the Java project and stencil in the root folder. The output is VDX but the same problem exists regardless of the output format.
In the code, I am just adding two rectangles and then a connector between the two.
When I set the connector text it is offset towards the beginning/start of the connector.
I’m still not clear on why the Props method doesn’t seem to work because I know I will have other cases where I would like to set shapesheet properties.
I’m still not clear on why the Props method doesn’t seem to work because I know I will have other cases where I would like to set shapesheet properties.
Thank you for being patient. Please note, you can add shape properties by initializing Prop class object and PropCollection class offers add method. Please elaborate a bit more about the Props method problem like which shape property are you setting? It’ll help us to be more specific.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.