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.

Mon Apr 19, 2021 9:45 pm

Hello there.

I want to add a horizontal line that is available in border menu like shown in the image, but I cannot find it anywhere in programming guide.
What is the method for it ? is it implemented ?
Image

Thanks in advance.

Leviamatte
 
Posts: 6
Joined: Sat Apr 17, 2021 2:20 pm

Tue Apr 20, 2021 10:09 am

Hello,

Thanks for your inquiry.
I am sorry that our Spire.Doc does not support adding the horizontal line directly like the MS Word. But this horizontal line is actually a shape, you can refer to the following code to draw a horizontal line shape to achieve a similar effect.
Code: Select all
            Document doc = new Document();
            doc.LoadFromFile("test.docx");
            Section section = doc.Sections[0];
            float width = section.PageSetup.PageSize.Width;
            float left = section.PageSetup.Margins.Left;
            float right = section.PageSetup.Margins.Right;
            section.Paragraphs[2].AppendShape(width-left-right, 0,ShapeType.Line);
            doc.SaveToFile("result.docx",FileFormat.Docx);


If there are other questions related to our products, please feel free to contact us.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Tue Apr 20, 2021 2:55 pm

Hello and thank you for your attention.
The thing is when you add the horizontal line with the option in border menu, it's width is automated and changes with column change,
but when you adding a shape as horizontal line, the width is not automated and line has a fixed width.
is there anyway to make the width of line auto fill or something ?

Leviamatte
 
Posts: 6
Joined: Sat Apr 17, 2021 2:20 pm

Wed Apr 21, 2021 10:22 am

Hello,

Thanks for your feedback.
I am sorry that our Spire.Doc does not yet support the feature you mentioned. But we will consider adding a new feature to support it. If it is implemented in the future, we will inform you immediately.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Wed Apr 21, 2021 6:13 pm

Hello

Until then I can add a table with top border and set to auto fit window and an "at least" line spacing of 0, so I can have a line whit automated width :)
I don't know if this will affect speed of saving large file but, have no other choice :D

Anyways, thank you for your great project and support.

Leviamatte
 
Posts: 6
Joined: Sat Apr 17, 2021 2:20 pm

Thu Apr 22, 2021 6:33 am

Hello,

Thanks for your feedback.
I am glad to hear that you have found a workaround. Anyway, if the new feature of adding horizontal lines whose width automatically adjusts with the page width is implemented in the future, we will let you know.

If you have any other questions, please do not hesitate to contact us.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Fri Jun 04, 2021 11:38 am

Hello,

Greetings from E-iceblue!
Glad to inform you that we just released Spire.Doc Pack Version:9.6 which adds a new feature to add horizontal line as the following code, please download it from the following links to test on your side. Looking forward to your test result.
Code: Select all
paragraph.AppendHorizonalLine();


Website link: https://www.e-iceblue.com/Download/down ... t-now.html
Nuget link: https://www.nuget.org/packages/Spire.Doc/9.6.0

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.Doc