We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

List item indent issue

Hi,


I am having an issue with my list item indents (Please see attached). What i want is to remove the space between the list number and the start of the text on the first line. The code i am currently using is

foreach (Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))
{
if (para.IsListItem)
{
ListFormat listFormat = para.ListFormat;
int listId = listFormat.List.ListId;
para.ParagraphFormat.FirstLineIndent = 10;
para.ParagraphFormat.FirstLineIndent = -10;
para.ParagraphFormat.LeftIndent = 10;
double tabStop = 10;
para.ParagraphFormat.TabStops.Add(new TabStop(tabStop, Aspose.Words.TabAlignment.Left, TabLeader.None));
<span style="color:#569cd6;">if</span> (listFormat<span style="color:#b4b4b4;">.</span>ListLevelNumber <span style="color:#b4b4b4;">></span> <span style="color:#b5cea8;">0</span>)
{
  <span style="color:#569cd6;">if</span> (<span style="color:#b4b4b4;">!</span>multiListIds<span style="color:#b4b4b4;">.</span>Contains(listId))
  {
    multiListIds<span style="color:#b4b4b4;">.</span>Add(listId);

    <span style="color:#569cd6;">if</span> (singleListIds<span style="color:#b4b4b4;">.</span>Contains(listId))
      singleListIds<span style="color:#b4b4b4;">.</span>Remove(listId);
  }
}
<span style="color:#569cd6;">else</span>
{
  <span style="color:#569cd6;">if</span> (<span style="color:#b4b4b4;">!</span>singleListIds<span style="color:#b4b4b4;">.</span>Contains(listId) <span style="color:#b4b4b4;">&&</span> <span style="color:#b4b4b4;">!</span>multiListIds<span style="color:#b4b4b4;">.</span>Contains(listId))
  {
    singleListIds<span style="color:#b4b4b4;">.</span>Add(listId);
  }
}

}
}

Hi Steve,


Thanks for your inquiry. Apart from tab character, the extra space is caused by ‘No-Break Space’ characters at the start of paragraphs. You can remove these characters from start of paragraph as follows:

Document doc = new Document(MyDir + @“Register+of+Mortgages+and+Charges+(5).docx”);

foreach (Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))

{

if (para.IsListItem)

{

if (para.ToString(SaveFormat.Text).StartsWith(((char)0x00A0).ToString()))

{

foreach (Run run in para.Runs)

{

run.Text = run.Text.Trim();

}

}

}

}

doc.Save(MyDir + @"15.10.0.docx");


Could you please also attach your expected document here for our reference. We will investigate the structure of your expected document as to how you want your final output be generated like. You can create expected document using Microsoft Word. We will then provide you code to achieve the same using Aspose.Words.

Best regards,