Shape.Rotation does not rotate the text of shape

Update:
the same problem in versions 21.7 -21.9
@tahir.manzoor

@aolo23

We have tested the scenario and managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-22754. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@aolo23

We have closed the issue WORDSNET-22754 as ‘Not a Bug’. Please use following code example to get the desired output.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);
Shape textBox = builder.insertShape(ShapeType.TEXT_BOX, 200, 50);

textBox.setWrapType(WrapType.NONE);
textBox.setRotation( 345 );

textBox.setHeight( 50.0 );
textBox.setWidth(200.0);

Node test = new Paragraph(doc);
textBox.appendChild( test );
Paragraph para = textBox.getFirstParagraph();
para.getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);

Run run = new Run(doc);
run.setText( "Content in textbox");
para.appendChild(run);
 
OoxmlSaveOptions options = new OoxmlSaveOptions();
options.setCompliance(OoxmlCompliance.ISO_29500_2008_STRICT);
doc.getCompatibilityOptions().optimizeFor(MsWordVersion.WORD_2019);

doc.save(MyDir + "output.docx", options);

Try to set top and left on the shape in your example and then you will see that nothing will change

textBox.setTop(800);
textBox.setLeft(900);

so I can rotate text but I cannot set the position … :stuck_out_tongue:

@aolo23

You are setting the position of Shape outside the page. Please set its position as shown below or set the position within the document’s page. We have attached the output document this post for your kind reference. 21.9.output.docx (8.1 KB)

textBox.setTop(80);
textBox.setLeft(90);