It doesn’t work when I set the Word indent value to 0, but it is normal to set other non-zero values.
Version info
Aspose.Words for Net 23.2
Sample Code
void Main()
{
Document doc = new Document(@"C:\Users\54390\Desktop\test.docx");
var nodes = doc.GetChildNodes(Aspose.Words.NodeType.Paragraph, true);
foreach (var m in nodes)
{
if (m is Aspose.Words.Paragraph p)
{
//The following three lines of code set invalid
p.ParagraphFormat.CharacterUnitFirstLineIndent = 0;
p.ParagraphFormat.CharacterUnitLeftIndent = 0;
p.ParagraphFormat.CharacterUnitRightIndent = 0;
}
}
doc.Save(@"C:\Users\54390\Desktop\output.docx");
}
Demo file
test.docx (16.5 KB)
@sullivan
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): WORDSNET-25172
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@alexey.noskov
Hello,Is there any progress on this issue? Thank you!
@sullivan The issue is currently in analysis. Once analysis is done we will provide you more information. As a temporary solution you can set both ParagraphFormat.CharacterUnitLeftIndent
and ParagraphFormat.LeftIndent
properties to zero, when zero value is required.
@sullivan We have completed analysis of the issue and decided to close it as not a bug. Aspose.Words produced result is exactly matching Word VBA result. However it seems that Word UI does additional processing and reset all indents.
We going to follow Word VBA behavior, so please reset all indents to achieve desired result.
// Please add following code.
p.ParagraphFormat.FirstLineIndent = 0;
p.ParagraphFormat.LeftIndent = 0;
p.ParagraphFormat.RightIndent = 0;
The issues you have found earlier (filed as WORDSNET-25172) have been fixed in this Aspose.Words for .NET 23.4 update also available on NuGet.