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);
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.
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);
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.