Free Support Forum - aspose.com

Shape text not rotated


#1

Problem marks as solved: Shape Rotate with text is not rendering as expected
Maybe, for Java version it’s true, but NET version still works wrong:
Next code is copy of Java variant from topic:

Document doc;
try {
doc = new Document();
Shape textBox = new Shape(doc, ShapeType.TextBox);
textBox.WrapType = WrapType.None;
textBox.Rotation = 345;

textBox.Height = 50;
textBox.Width = 50;

Node test = new Paragraph(doc);
textBox.AppendChild(test);
Paragraph para = textBox.FirstParagraph;
para.ParagraphFormat.Alignment = ParagraphAlignment.Center;

Run run = new Run(doc);
run.Text = “Content in textbox”;
para.AppendChild(run);

doc.FirstSection.Body.FirstParagraph.AppendChild(textBox);

doc.Save(@“C:\Watermark.doc”);

} catch (System.Exception e)
{

}

Result: Watermark.zip (2.0 KB)


#2

@tvv91,

We tested the scenario and have managed to reproduce the same problem on our end. For the sake of correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-18126. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.


#3

@tvv91,

Regarding WORDSNET-18126, it seems MS Word supports rotation of text in textbox for DML shapes only. So, please try to use OoxmlSaveOptions with OoxmlCompliance “Transitional” or “Strict” (as in the code example below). If you still have any issues with this, please provide doc example with expected result created by using MS Word.

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

Shape textbox = builder.InsertShape(ShapeType.TextBox, 200, 100);
textbox.Rotation = 180;

Console.WriteLine(textbox.MarkupLanguage);

Paragraph par = new Paragraph(doc);
textbox.AppendChild(par);
par.AppendChild(new Run(doc, "This is test content"));

OoxmlSaveOptions so = null;
if (doc.Compliance < OoxmlCompliance.Iso29500_2008_Transitional)
{
  so = new OoxmlSaveOptions(SaveFormat.Docx);
  // Textbox must be saved as DML shape to enable rotation. So, OOXML compliance
  // must be "Transitional" or "Strict".
  so.Compliance = OoxmlCompliance.Iso29500_2008_Transitional;
}

doc.Save(@"Out.docx", so);