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

Free Support Forum - aspose.com

Problem in Aspose Word for HTML bulleted text - Adding extra space in the end

Hello,

We tried with the work around provided by as using listItems and revisiting the paragraph to set the margin. For some extent it is working.

The problem is the bullets appearing on the page when the left margin is set as 30, 45 and 70.

Attached are the various output files for your consideration.

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Problems are as follows,

  1. when left margin is set as 30 the bullets are very near to the text.
  2. when left margin is set as 45 or 70 bullets are not with the spacing as having margin as 30.
  3. Also the first bullet appears as bold and big in size as compared with others in the same document.

Regards,

Dwarika

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. I think, You can try playing with ListLevel.NumberPosition, ListLevel.TabPosition, ListLevel.TextPosition to configure each level of your list (see the attached screenshot). Please see the following link for more information:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net-and-java/aspose.words.lists.listlevel.html

Also, I think, the information provide in the following thread could be useful for you.

Best regards.

Hello Alexey,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I have gone through both the links you have provided and have following doubt,

There are settings like

level1.NumberPosition = -36;
level1.TextPosition = 144;
level1.TabPosition = 144;

-36, 144 and 144 are these values hardcoded? I mean if we want to set these numbers as per the margin setting what should be the value?

I am using following code in my sample application to set above parameters,

string path = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);

//Initialize Aspose license. Aspose Word version 9.0.0.0

Aspose.Words.License lic = new Aspose.Words.License();

lic.SetLicense(path + @"\Aspose.Total.lic");

Aspose.Pdf.License lic1 = new Aspose.Pdf.License();

lic1.SetLicense(path + @"\Aspose.Total.lic");

Document doc = new Document();

DocumentBuilder documentBuilder = new DocumentBuilder(doc);

Run run;

Aspose.Words.Font font;

//set the page set-up

PageSetup pageSetup = documentBuilder.CurrentSection.PageSetup;

pageSetup.PaperSize = PaperSize.A4; //set the page size.

pageSetup.LeftMargin = 50;

documentBuilder.ParagraphFormat.ClearFormatting();

//set font

run = new Run(doc);

font = run.Font;

documentBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left;

font.Name = "Arial Unicode MS";

font.Size = 11;

font.Italic = false;

string strBullet = "Paragraph for bullet points:

  • First bullet point
  • Second bullet point
  • Third bullet point
  • <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />Forth bullet point
";

Paragraph currNode = documentBuilder.CurrentParagraph;

documentBuilder.InsertHtml("Document to test bullets in a paragraph");

documentBuilder.InsertBreak(BreakType.LineBreak);

documentBuilder.InsertHtml("Paragraph for bullet points:
"
);

documentBuilder.InsertHtml(strBullet);

//documentBuilder.InsertHtml("Text after bullet points");

do

{

if (currNode.NodeType == NodeType.Paragraph)

{

Paragraph currentParagraph = (Paragraph)currNode;

currNode.ParagraphFormat.LeftIndent = 50;

if (currNode.IsListItem)

{

currNode.ListFormat.ListLevel.NumberPosition = 50;

currNode.ListFormat.ListLevel.TextPosition = 50;

currNode.ListFormat.ListLevel.TabPosition = 50;

}

// move to next node

currNode = (Paragraph)currNode.NextSibling;

}

} while (currNode != null && !currNode.Equals(documentBuilder.CurrentParagraph));

// Loop through all paragraphs and reset auto spacing.

NodeCollection paragraphs = doc.GetChildNodes(NodeType.Paragraph, true);

foreach (Paragraph paragraph in paragraphs)

{

paragraph.ParagraphFormat.SpaceAfterAuto = false;

paragraph.ParagraphFormat.SpaceAfter = 0;

}

documentBuilder.InsertHtml("Text after bullet points");

doc.Save("HTML_Bullets_12Oct2010.doc");

StartWord("HTML_Bullets_12Oct2010.doc");

Bulleted list should use the margin set for the page (in this case I am using left margin as 50 & therefore I have set NumberPosition, TextPosition and TabPosition as 50.

Do let me know what is wrong with the above code and how do we rectify the spacing between the bullet and the text when the margin value is changed.

Also whether we need to use all the three (NumberPosition, TextPosition and TabPosition) to set bulletted text?

Regards,

Dwarika

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Note: Indent of paragraph is distance from left margin of page to text, but not distance from left edge of page to text.

Please try using this code:

Document doc = new Document();

DocumentBuilder documentBuilder = new DocumentBuilder(doc);

Run run;

Aspose.Words.Font font;

//set the page set-up

PageSetup pageSetup = documentBuilder.CurrentSection.PageSetup;

pageSetup.PaperSize = PaperSize.A4; //set the page size.

pageSetup.LeftMargin = 50;

documentBuilder.ParagraphFormat.ClearFormatting();

//set font

run = new Run(doc);

font = run.Font;

documentBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left;

font.Name = "Arial Unicode MS";

font.Size = 11;

font.Italic = false;

string strBullet = "Paragraph for bullet points:

  • First bullet point
  • Second bullet point
  • Third bullet point
  • Forth bullet point
";

Paragraph currNode = documentBuilder.CurrentParagraph;

documentBuilder.InsertHtml("Document to test bullets in a paragraph");

documentBuilder.InsertBreak(BreakType.LineBreak);

documentBuilder.InsertHtml("Paragraph for bullet points:
"
);

documentBuilder.InsertHtml(strBullet);

//documentBuilder.InsertHtml("Text after bullet points");

do

{

if (currNode.NodeType == NodeType.Paragraph)

{

Paragraph currentParagraph = (Paragraph)currNode;

if (currNode.IsListItem)

{

currNode.ListFormat.ListLevel.NumberPosition = 0;

currNode.ListFormat.ListLevel.TextPosition = 30;

currNode.ListFormat.ListLevel.TabPosition = 30;

}

// move to next node

currNode = (Paragraph)currNode.NextSibling;

}

} while (currNode != null && !currNode.Equals(documentBuilder.CurrentParagraph));

// Loop through all paragraphs and reset auto spacing.

NodeCollection paragraphs = doc.GetChildNodes(NodeType.Paragraph, true);

foreach (Paragraph paragraph in paragraphs)

{

paragraph.ParagraphFormat.SpaceAfterAuto = false;

paragraph.ParagraphFormat.SpaceAfter = 0;

}

documentBuilder.InsertHtml("Text after bullet points");

doc.Save(@"Test001\out.doc");

Best regards,

Hello Alexey,

Thanks very much for inputs. I tried using setting currNode.ListFormat.ListLevel.NumberPosition = 0;

but below two properties i am using the value of Page left margin as this is the system requirement.

currNode.ListFormat.ListLevel.TextPosition = 50;<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

currNode.ListFormat.ListLevel.TabPosition = 50;

but still it is not working.Attached is the output after doing above change.

What we want is bullet point should start right below the title "

Test Bullet" and there should not be any gap / space between the bullet and the text.

I hope you have understood my problem.

Do let me know if there is any other workaround.

Regards,

Dwarika

Hi Dwarika,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. Could you please also share your HTML here? I tested with code I posted in my previous post and the generated document looks fine. Have you tried with the code I posted?

Best regards,

Hello Alexey,

I have used the code that you have provided in the earlier post. Because of that code sample only bullets are working as per requirement to some extent.

But like the problems i have listed down in my earlier post are not yet resolved.

Following strings we are using to display bullets in word output

1.

  • This is step 1

  • This is step 2

  • This is step 3

2. This is a bulleted text:

  • This is step 1

  • This is step 2

  • This is step 3

Regards,

Dwarika

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. As I can see, HTML is the same as I used in the code example. I attached my output document. As you can see, it looks correct.

Best regards,

Hi Alexy,


Thanks for your reply.
Can you please let me know on which version of Aspose you have verified this?

Regards,
Dwarika

Hi Dwarika,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. We always use the latest version of Apsose.Words for testing. You can download the latest version from here:

http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/category1188.aspx

Best regards,

Hello Alexey,

We have upgraded Aspose.Words from 9.0 to 9.5 and verified the bullet point issue with new version.

Still we feel this issue is not resolved.

Attcahed is the output renderred using Aspose.Words 9.5.

Space between the bullet and the text appears to be different with different left indent setting.

Regards,

Dwarika

Hi Dwarika,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. As I already mentioned I cannot reproduce the problem on my side. I also attached my output document in my previous answer. As you also can see the output document produced on my side looks correct. So, please provide me full code that will allow me to reproduce the problem out output and expected output documents.

Best regards,

Hello Alexey,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Here is the sample code that I am using to test HTML bullets.

We are facing problem with in-consistent space between bullet and text when left margin is set with different values.

string path = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);

//Initialize Aspose license. Aspose Word version 9.5.0.0

Aspose.Words.License lic = new Aspose.Words.License();

lic.SetLicense(path + @"\Aspose.Total.lic");

Aspose.Pdf.License lic1 = new Aspose.Pdf.License();

lic1.SetLicense(path + @"\Aspose.Total.lic");

Document doc = new Document();

DocumentBuilder documentBuilder = new DocumentBuilder(doc);

Run run;

Aspose.Words.Font font;

double leftMargin = 0;

//set the page set-up

PageSetup pageSetup = documentBuilder.CurrentSection.PageSetup;

pageSetup.PaperSize = PaperSize.A4; //set the page size.

pageSetup.LeftMargin = leftMargin;

documentBuilder.ParagraphFormat.ClearFormatting();

//set font

run = new Run(doc);

font = run.Font;

documentBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left;

font.Name = "Arial Unicode MS";

font.Size = 11;

font.Italic = false;

string strBullet = "Paragraph for bullet points:

  • First bullet point
  • Second bullet point
  • Third bullet point
  • <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />Forth bullet point
";

Paragraph currNode = documentBuilder.CurrentParagraph;

documentBuilder.InsertHtml("Document to test bullets in a paragraph");

documentBuilder.InsertBreak(BreakType.LineBreak);

documentBuilder.InsertHtml("Left Margin Set for page is: "+ leftMargin.ToString());

documentBuilder.InsertBreak(BreakType.LineBreak);

documentBuilder.InsertHtml("Paragraph for bullet points:
"
);

documentBuilder.InsertHtml(strBullet);

do

{

if (currNode.NodeType == NodeType.Paragraph)

{

Paragraph currentParagraph = (Paragraph)currNode;

currNode.ParagraphFormat.LeftIndent = leftMargin;

if (currNode.IsListItem)

{

currNode.ListFormat.ListLevel.NumberPosition = leftMargin;

currNode.ListFormat.ListLevel.TextPosition = leftMargin;

currNode.ListFormat.ListLevel.TabPosition = leftMargin;

}

// move to next node

currNode = (Paragraph)currNode.NextSibling;

}

} while (currNode != null && !currNode.Equals(documentBuilder.CurrentParagraph));

// Loop through all paragraphs and reset auto spacing.

NodeCollection paragraphs = doc.GetChildNodes(NodeType.Paragraph, true);

foreach (Paragraph paragraph in paragraphs)

{

paragraph.ParagraphFormat.SpaceAfterAuto = false;

paragraph.ParagraphFormat.SpaceAfter = 0;

}

documentBuilder.InsertHtml("Text after bullet points");

doc.Save("HTML_Bullets_06Jan2011(LeftMargin=0).doc");

StartWord("HTML_Bullets_06Jan2011(LeftMargin=0).doc");

Also refer to following attachments,

  1. NumberPosition=0(2011Jan06).rar - This folder contains output with left margin is set with 0 to 50 and NumberPosition is set to zero (0)

Also take a look at Difference Between Bullet and Text.doc inside this folder for comparison between various margins and space between bullet and text.

  1. NumberPosition=LeftMargin(2011Jan06).rar This folder contains output with left margin is set with 0 to 50 and NumberPosition is set same as left margin

Also take a look at Difference Between Bullet and Text.doc inside this folder for comparison between various margins and space between bullet and text.

Regards,

Dwarika

Hi Dwarika,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. The problem occurs because you set tab position the same as number position. That is why default tab stop is used and you do not get the expected result. Please see the following modified code:

do

{

if (currNode.NodeType == NodeType.Paragraph)

{

Paragraph currentParagraph = (Paragraph)currNode;

currNode.ParagraphFormat.LeftIndent = leftMargin;

if (currNode.IsListItem)

{

currNode.ListFormat.ListLevel.NumberPosition = leftMargin;

currNode.ListFormat.ListLevel.TextPosition = leftMargin;

// Tab position should not be less or equel number position.

// If they are equel default tab stop will be used and you will not get the expected tab position.

// That is why you should increase tab position. In this case distance from bult to text will be expected.

currNode.ListFormat.ListLevel.TabPosition = leftMargin + 20;

}

// move to next node

currNode = (Paragraph)currNode.NextSibling;

}

} while (currNode != null && !currNode.Equals(documentBuilder.CurrentParagraph));

Also, please see my comments in the code. Hope this helps.

Best regards,

Hello Alexey,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your reply and suggestion. I tried by increasing TabPosition as you have stated and it worked for me.

Still I have one query, do we have to default TabPosition = margin + 20?

As I have also tested using 10 and in the output the space between bullet point and text was reduced.

So increasing TabPosition by some number adjust the space between the bullet and the text.

Please confirm.

Regards,

Dwarika

Hi Dwarika,

Thanks for your request. Yes, you are right changing TabPosition will change distance between bullet and text.

Best regards,

Hello Alexey,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your quick reply and valuable support. I managed to get this in correct manner as far as LRT languages are concerned. However when I tried same code by doing changes that will fir RTL languages for margins 25 onwards the bullet points are not aligned with the text before them. Below is the sample code for RTL test.

string path = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);

//Initialize Aspose license. Aspose Word version 9.5.0.0

Aspose.Words.License lic = new Aspose.Words.License();

lic.SetLicense(path + @"\Aspose.Total.lic");

Aspose.Pdf.License lic1 = new Aspose.Pdf.License();

lic1.SetLicense(path + @"\Aspose.Total.lic");

Document doc = new Document();

DocumentBuilder documentBuilder = new DocumentBuilder(doc);

Run run;

Aspose.Words.Font font;

double leftMargin = 0;

double rightMargin = 50;

double increasedTabPosition = 20;

//set the page set-up

PageSetup pageSetup = documentBuilder.CurrentSection.PageSetup;

pageSetup.PaperSize = PaperSize.A4; //set the page size.

pageSetup.LeftMargin = leftMargin;

pageSetup.RightMargin = rightMargin;

documentBuilder.ParagraphFormat.ClearFormatting();

//set font

run = new Run(doc);

font = run.Font;

documentBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left;

font.Name = "Arial Unicode MS";

font.Size = 11;

font.Italic = false;

//string strBullet = "

Paragraph for bullet points:

  • First bullet point
  • Second bullet point
  • Third bullet point
  • <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />Forth bullet point

";

string strBullet = "

فقرة عن النقاط :

  • أول رصاصة نقطة
  • الرصاصة الثانية نقطة
  • ثالث رصاصة نقطة
  • عليها رصاصة نقطة

";

Paragraph currNode = documentBuilder.CurrentParagraph;

//documentBuilder.InsertHtml("

Document to test bullets in a paragraph

");

documentBuilder.InsertHtml("

وثيقة لاختبار الرصاص في فقرة

");

documentBuilder.InsertBreak(BreakType.LineBreak);

//documentBuilder.InsertHtml("

Left Margin Set for page is: " + leftMargin.ToString() + " Tab Position Increased by: " + increasedTabPosition.ToString() + "

");

documentBuilder.InsertHtml("

تعيين الهامش الأيسر للصفحة هو : "

+ rightMargin.ToString() + " زيادة تبويب المركز من قبل : " + increasedTabPosition.ToString() + "

");

documentBuilder.InsertBreak(BreakType.LineBreak);

//documentBuilder.InsertHtml("

Paragraph for bullet points:

");

documentBuilder.InsertHtml("

فقرة عن النقاط :

"

);

documentBuilder.InsertHtml(strBullet);

do

{

if (currNode.NodeType == NodeType.Paragraph)

{

Paragraph currentParagraph = (Paragraph)currNode;

currNode.ParagraphFormat.RightIndent = rightMargin;

if (currNode.IsListItem)

{

currNode.ListFormat.ListLevel.NumberPosition = rightMargin;

currNode.ListFormat.ListLevel.TextPosition = rightMargin;

currNode.ListFormat.ListLevel.TabPosition = rightMargin + increasedTabPosition;

}

// move to next node

currNode = (Paragraph)currNode.NextSibling;

}

} while (currNode != null && !currNode.Equals(documentBuilder.CurrentParagraph));

// Loop through all paragraphs and reset auto spacing.

NodeCollection paragraphs = doc.GetChildNodes(NodeType.Paragraph, true);

foreach (Paragraph paragraph in paragraphs)

{

paragraph.ParagraphFormat.SpaceAfterAuto = false;

paragraph.ParagraphFormat.SpaceAfter = 0;

}

documentBuilder.InsertBreak(BreakType.LineBreak);

documentBuilder.ParagraphFormat.RightIndent = rightMargin;

//documentBuilder.InsertHtml("

Text after bullet points

");

documentBuilder.InsertHtml("

النص بعد النقاط

");

doc.Save("HTML_Bullets_07Jan2011(RightMargin=0).doc");

StartWord("HTML_Bullets_07Jan2011(RightMargin=0).doc");

Also take a look at RTL sample documents for different margin settings.

Regards,

Dwarika

Hi Dwarika,

Thanks for your request. The following code should give you the expected result:

do

{

if (currNode.NodeType == NodeType.Paragraph)

{

currNode.ParagraphFormat.LeftIndent = leftMargin;

if (currNode.IsListItem)

{

currNode.ListFormat.ListLevel.NumberPosition = leftMargin;

currNode.ListFormat.ListLevel.TextPosition = leftMargin;

currNode.ListFormat.ListLevel.TabPosition = leftMargin + increasedTabPosition;

}

// move to next node

currNode = (Paragraph)currNode.NextSibling;

}

} while (currNode != null && !currNode.Equals(documentBuilder.CurrentParagraph));

Best regards,

The issues you have found earlier (filed as WORDSNET-2104) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(2)

A post was split to a new topic: Document Conversion to RTF always give extra space after bulleting