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 Nov 21, 2023 9:28 am

The LeftIndent is not working.

Code: Select all
        Document document = new Document();

        // Add a paragraph to the document
        Section section = document.AddSection();
        Paragraph paragraph = section.AddParagraph();

        // Set the left indentation (in points)
        paragraph.Format.LeftIndent = 20;

        // Set the first line indentation (in characters)
        paragraph.Format.FirstLineIndentChars = 2;

        // Save the document
        document.SaveToFile("output.docx", FileFormat.Docx);

Peter1209
 
Posts: 6
Joined: Mon Jan 14, 2019 3:12 pm

Wed Nov 22, 2023 1:33 am

Hello,

Thank you for your inquiry.
I have tested the code you provided using the latest version of Spire.Doc (Spire.Doc Pack(hot fix) Version:11.11.0), and I can confirm that the "LeftIndent" property is working as expected, as shown in the screenshot below.
screenshot.png

Could you please confirm whether you are using the latest version of Spire.Doc for your testing as well? If not, I recommend upgrading to the latest version and retesting the code.
If the issue still exist after updating to the latest version, please provide the following information for our reference. Thanks in advance.
1) Your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese).
2) Your application type, such as Console app (.Net5).

Sincerely
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Wed Nov 22, 2023 2:03 am

Hello,

Sorry, The FirstLineIndentChars is negative.

Code: Select all
paragraph.Format.FirstLineIndentChars = -2;
paragraph.Format.LeftIndent = 20;



Env:
Net6 console app
ubuntu (docker image)
spire.doc 11.11.0

Word Env:
windows office 2010

Peter1209
 
Posts: 6
Joined: Mon Jan 14, 2019 3:12 pm

Wed Nov 22, 2023 5:42 am

Hello,

Thank you for providing the information.
Please note that when the value of "FirstLineIndentChars" is negative, the paragraph's first-line indentation behaves as a hanging indent. In this case, the unit for the "LeftIndent" property can only be specified in characters and not in points. This means that the code you tested, where the "LeftIndent" value was provided in points, will not have the desired effect.
Currently, we do not support setting the unit of "LeftIndent" to characters. I have recorded this feature request in our upgrade list.
Rest assured, once this feature is implemented in the future, I will notify you promptly.

Sincerely
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Thu Feb 01, 2024 3:32 am

Hello,

Glad to inform that we just released Spire.Doc Pack(hot fix) Version:12.1.17 which supports setting the unit of "LeftIndent" to characters, please download and refer to the sample code for testing.

Website link: https://www.e-iceblue.com/Download/download-word-for-net-now.html
Nuget link: https://www.nuget.org/packages/Spire.Doc/12.1.17
Code: Select all
// Set the first line indentation (in characters)
paragraph.Format.FirstLineIndentChars = -2;

// Set the left indentation (in characters)
paragraph.Format.LeftIndentChars = 2;

Sincerely
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.Doc