Space in the left, although LeftPadding = 0

Hi there,

I am wondering, using code below, although i have set Leftpadding=0, but there is still space:

  if (test2)
  {
      if (j == 0)
      {
          builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(ConvertUtil.InchToPoint(1.74));
      }
      else if (j == 1)
      {
          builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(ConvertUtil.InchToPoint(4.51));
          builder.CellFormat.LeftPadding = 0;   // no work
      }
  }

  if (j == 1)
  {
      

      font2.Size = 8;

     
      builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
      
      List lst = doc.Lists.Add(ListTemplate.BulletSquare);
      builder.ListFormat.List = lst;
      builder.InsertHtml(ssAAssetCritical[i, j], true);
      builder.ListFormat.RemoveNumbers();

  }

What cause the space and how to remove it? (in the doc attached, it is on page 31). I try using:
builder.ParagraphFormat.LeftIndent = 0;
but it does not work, although in MS-Word, it change the indent of paragraph manually to 0, it works.

best

DISP SRA (33).docx (269.3 KB)

regards

@ibox Please try specifying number position:

List lst = doc.Lists.Add(ListTemplate.BulletSquare);
lst.ListLevels[0].NumberPosition = 0;
builder.ListFormat.List = lst;
builder.InsertHtml("<span>test</span>", true);

Thank you Sir,

I tried, but it does not work.

List lst = doc.Lists.Add(ListTemplate.BulletSquare);
lst.ListLevels[0].NumberPosition = 0;
builder.ListFormat.List = lst;
builder.InsertHtml(ssAAssetCritical[i, j], true);
builder.ListFormat.RemoveNumbers();

regards

@ibox Try also setting left indent of the paragraph to zero.

See ParagraphFormat.LeftIndent property.

thank you, Sir

It still does not work, until i put:
lst.ListLevels[0].TextPosition = 0;

It is much better now, the spacing is narrower. But cannot up to the left most.

I try to set the indentation in Ms Words, in addition to those lines, it works if we set the “follow with number” with “nothing”. I try using:
lst.ListLevels[0].TabPosition = 0;

but it does not work.

How to set that “nothing”?

best regards

narrower space:


nothing:

DISP SRA (2).docx (269.3 KB)

@ibox In your case you should also set trailing character to nothing. For example see the following simplified document and code:

Document doc = new Document(@"C:\Temp\in.docx");

Cell cell = doc.FirstSection.Body.Tables[0].Rows[1].Cells[1];
foreach (Paragraph p in cell.Paragraphs)
{
    if (p.IsListItem)
    {
        p.ListFormat.ListLevel.NumberPosition = 0;
        p.ListFormat.ListLevel.TrailingCharacter = ListTrailingCharacter.Nothing;
    }

}

doc.Save(@"C:\Temp\out.docx");

in.docx (49.4 KB)

out.docx (35.3 KB)