Free Support Forum - aspose.com

Text wraps to wrong spot in document


I want the text when it wraps to be even with the text not the letter in the list. but instead it makes the wrapped text appear way out to the left with the letter above it.

How do I make thet ext wrap flush with the other text and not the letter.

l. System alarms and system messages, current and previous
m. Adjustable water skim duration
n. Programmable outputs for remote signaling of alarms and/or messages, device activation (such as a fan), or for signaling tank heating and/or steam production

Hi David,


Thanks for contacting support.

Can you please share which product you are using and the intended output format which you need to generate. Please share some details so that we can reply accordingly.

I am using aspose Words. using documentBuilder to build document.


I am bilding a list as

com.aspose.words.List numberedList1 = doc.getLists().addCopy(numberedList);
numberedList1.getListLevels().get(0).setStartAt(1);
builder.getListFormat().setList(numberedList1);

then when I write a line like this line

builder.writeln(“Plastic disposable steam cylinder shall have welded seams to ensure that cylinder is watertight, provide full output for entire cylinder life, and have integral high water sensor probe to prevent overfilling.”);

it wraps, but it wraps to be flush the number not the start of the text. I want it to wrap and be even with the start of the text.

Hi David,


Thanks for sharing the information.

I am moving this thread to Aspose.Words forum and my fellow workers taking care of this product will answer shortly.

Hi David,


Thanks for your inquiry. In case you are using an older version of Aspose.Words, I would suggest you please upgrade to the latest version (v13.3.0.1) from here and let us know how it goes on your side.

Moreover, please note that ParagraphFormat.setFirstLineIndent method sets the value (in points) for a first line or hanging indent. Use a positive value to set a first-line indent, and use a negative value to set a hanging indent. Please see the following code snippet for your kind reference.

Document doc = new
Document();<o:p></o:p>

DocumentBuilder builder = new DocumentBuilder(doc);

com.aspose.words.List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT);

com.aspose.words.List numberedList1 = doc.getLists().addCopy(list);

numberedList1.getListLevels().get(0).setStartAt(1);

builder.getListFormat().setList(numberedList1);

Paragraph para = builder.getCurrentParagraph();

para.getParagraphFormat().setFirstLineIndent(10.0);

para.getParagraphFormat().setFirstLineIndent(-10.0);

builder.writeln("Plastic disposable steam cylinder shall have welded seams to ensure that cylinder is watertight, provide full output for entire cylinder life, and have integral high water sensor probe to prevent overfilling.");

doc.save(MyDir + "out.docx");


If the problem still remains, please attach your input Word document here for testing. I will investigate the issue on my side and provide you more information.

I am using lists configuration perhaps incorrectly as follows.


ListLevel level1 = numberedList.getListLevels().get(0);
level1.setStartAt(1);
level1.setNumberPosition(30);
level1.getFont().setBold(false);
level1.getFont().setSize(heading4);
level1.setTextPosition(30);
level1.setTabPosition(40);
ListLevel level2 = letterList.getListLevels().get(0);
level2.getFont().setSize(heading3);
level2.getFont().setBold(false);
level2.setStartAt(1);
level2.setNumberPosition(20);
level2.setTextPosition(20);
level2.setTabPosition(30);
ListLevel level4 = littleLetterList.getListLevels().get(0);
level4.getFont().setSize(heading5);
level4.getFont().setBold(false);
level4.setStartAt(1);
level4.setNumberPosition(40);
level4.setTextPosition(30);
level4.setTabPosition(50);

What is the tab position? Presumable the number position is where the number should appear. And the text position is where the text should appear. Or at least for the first line, but when it wraps it left justifies. ignoring the number position and the text position values…

Hi David,


Thanks for your inquiry. The ListLevel.setTabPosition method sets the tab position (in points) for the list level. Please see the attached image for detail.

ListLevel.setTextPosition method sets the position (in points) for the second line of wrapping text for the list level.

ListLevel.setNumberPosition method sets the position (in points) of the number or bullet for the list level.

Please change the values for setTabPosition, setNumberPosition and setTextPosition methods in the following code snippet and check the output. Hope this helps you. Please let us know if you have any more queries.

Document doc = new
Document();<o:p></o:p>

DocumentBuilder builder = new DocumentBuilder(doc);

// Create a list.

com.aspose.words.List list = doc.getLists().add(ListTemplate.NUMBER_ARABIC_DOT);

ListLevel level1 = list.getListLevels().get(0);

// Modify list if required.

level1.setNumberStyle(NumberStyle.ARABIC);

level1.setNumberFormat("\u0000)");

level1.setNumberPosition(-20);

level1.setTextPosition(100);

level1.setTabPosition(100);

ListLevel level2 = list.getListLevels().get(1);

level2.setNumberStyle(NumberStyle.ARABIC);

level2.setNumberFormat("\u0000.\u0001)");

level2.setNumberPosition(-40);

level2.setTextPosition(0);

level2.setTabPosition(200);

// Create few items.

builder.getListFormat().setList(list);

builder.writeln("This is the first level This is the first level This is the first level This is the first level This is the first level ");

builder.getListFormat().listIndent();

builder.writeln("This needs to be more text on ListLevel 0 without it being numbered.");

// Stop buildign the list.

builder.getListFormat().removeNumbers();

builder.writeln("This needs to be more text on ListLevel 0 without it being numbered.");

// Start buildign the list.

builder.getCurrentParagraph().getListFormat().setList(list);

builder.getListFormat().listOutdent();

builder.writeln("This is the first level again");

builder.getListFormat().listIndent();

builder.writeln("Test");

// Stop buildign the list.

builder.getListFormat().removeNumbers();

builder.getDocument().save(MyDir + "Out.docx");

It doing this no matter it seem how I set those paramters.


a. Each tublet shall extend through the wall of the dispersion tube and incorporate a properly
sized calibrated orifice.

first the big space between the letter in this case and the text, then the second line should line up with the first line. How do I correct both cases. Thank you.

Hi David,


Thanks for your inquiry. Please use the following code snippet to achieve your requirement. This code example sets the value of first Paragraph in the document for TabPosition, NumberPosition and TextPosition. Hope this helps you.

If the problem still remains, please attach your input Word document here for testing. I will investigate the issue on my side and provide you more information.

Document doc = new
Document(MyDir + “list.docx”);<o:p></o:p>

Paragraph para = (Paragraph)doc.getChild(NodeType.PARAGRAPH, 0, true);

if (para.isListItem())

{

para.getListFormat().getListLevel().setTabPosition(0.0);

para.getListFormat().getListLevel().setNumberPosition(0);

para.getListFormat().getListLevel().setTextPosition(0.0);

para.getParagraphFormat().setFirstLineIndent(10.0);

para.getParagraphFormat().setFirstLineIndent(-10.0);

}

doc.save(MyDir + "out.docx");


Please note that ParagraphFormat.setFirstLineIndent method sets the value (in points) for a first line or hanging indent. Use a positive value to set a first-line indent, and use a negative value to set a hanging indent. Please see my reply from here:
https://forum.aspose.com/t/56104