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.

Tue Jan 05, 2021 4:03 am

Quick question. . .

I have a form that has textboxes associated with paragraphs.

I would like to vary the location of the textboxes. . .ie, some at the top of their respective paragraphs, some at the bottom, some on the left, some in the center, etc.

It seems to me that you should be able to do that with something like this. . .

Spire.Doc.Fields.TextBox textBox2 = paragraph.AppendTextBox(200, 70);
textBox2.Format.HorizontalAlignment = ShapeHorizontalAlignment.Left;
textBox2.Format.VerticalAlignment = ShapeVerticalAlignment.Bottom;

Sadly, the Horizontal and Vertical Alignment commands don't seem to do much of anything.

What to do??

Thanks!!

Narniaman
 
Posts: 5
Joined: Sun Mar 01, 2020 2:24 am

Tue Jan 05, 2021 5:58 am

Hello,

Thanks for your inquiry.
Please refer to the modified code below and download the latest Spire.Doc Pack(hot fix) Version:8.12.14 for testing. If there are any questions, please provide your desired output for our reference.
Code: Select all
            Document doc = new Document();
            doc.LoadFromFile("test.docx");
            Section section = doc.Sections[0];
            Paragraph paragraph = section.Paragraphs[0];
            TextBox textBox2 = paragraph.AppendTextBox(200, 70);
            textBox2.Format.HorizontalOrigin = HorizontalOrigin.Column;
            textBox2.Format.HorizontalAlignment = ShapeHorizontalAlignment.Left;
            textBox2.Format.VerticalOrigin = VerticalOrigin.Line;       
            textBox2.Format.VerticalAlignment = ShapeVerticalAlignment.Bottom;
            doc.SaveToFile("result.docx", FileFormat.Docx);


My output:
My output.png

Sincerely,
Rachel
E-iceblue support team
User avatar

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

Mon Jan 11, 2021 1:55 am

Hello,

Greetings from E-iceblue!
Has your issue been resolved? Looking forward to your feedback!

Sincerely,
Rachel
E-iceblue support team
User avatar

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

Return to Spire.Doc