Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Thu Jul 07, 2016 1:59 am

Hi,

Is it possible to set the direction of the text inside a TextBox?

Thanks,

Matias,

matimont
 
Posts: 2
Joined: Thu Jul 07, 2016 1:08 am

Thu Jul 07, 2016 6:55 am

Dear Matias,

Thanks for your inquiry.
Did you want to set the text direction as RTL ? If so, here is sample code for your reference:
Code: Select all
            Document doc = new Document();
            Section sec = doc.AddSection();
            Paragraph par = sec.AddParagraph();
            Spire.Doc.Fields.TextBox TB = par.AppendTextBox(100, 20);
            //add paragraph and set the text direction as RTL
            Paragraph para = TB.Body.AddParagraph();
            para.Format.IsBidi = true;
            TextRange TR = para.AppendText("Textbox in Word Document");
            TR.CharacterFormat.Bidi = true;
            doc.SaveToFile("8023.docx",FileFormat.Docx);

If I misunderstand, please let me know.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Fri Jul 08, 2016 8:52 am

Dear Matias,

Did the codes help you ? Has your issue been resolved ?
Thanks for your feedback.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Fri Jul 08, 2016 2:51 pm

Hi Betsy, not really. I want to set the text direction inside the TextBox so that the text will be vertical rather than the default horizontal.

Here's my code for reference:

Paragraph para1 = TB0.Body.AddParagraph();
TextRange TR = para1.AppendText("Test Text");
TR.CharacterFormat.FontName = "Calibri";
TR.CharacterFormat.FontSize = 8;
TR.CharacterFormat.TextColor = Color.Black;


Spire.Doc.Fields.TextBox TB1 = word.Sections[0].AddParagraph().AppendTextBox(154, 100);
TB1.Format.HorizontalPosition = 35;
TB1.Format.VerticalPosition = 0;
TB1.Format.LineStyle = TextBoxLineStyle.Simple;
TB1.Format.LineColor = Color.Black;
TB1.Format.LineDashing = LineDashing.Solid;
TB1.Format.LineWidth = 0.75F;

matimont
 
Posts: 2
Joined: Thu Jul 07, 2016 1:08 am

Mon Jul 11, 2016 3:05 am

Dear Matias,

Thanks for your feedback.
Sorry that Spire.Doc doesn't support to set the text direction inside the TextBox as vertical at present, but we have added this new feature into our schedule. Once it is done, we will let you know.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Tue Jun 22, 2021 6:01 am

Hello,

Sorry for the long silence.
Glad to tell you that our Spire.Doc already supports setting the text direction inside the TextBox. Please download the latest Spire.Doc Pack(hot fix) Version:9.6.10 and refer to the following code snippet for testing.

Code: Select all
    //...
    Spire.Doc.Fields.TextBox TB = par.AppendTextBox(100, 400);
    TB.Format.LayoutFlowAlt = TextDirection.RightToLeft;
    //...


Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.Doc