Hi Team,
Hi Team,
Hi Tahir,
This is non bulleted line<o:p></o:p>
- This is bulleted line
- This is line with hash bullet
· This is line with circled bullet.
Need to customize spacing between them
Hi Tahir,
setTabPosition(doublevalue) : Returns or sets the tab position (in points) for the list level.
Is this method sets the spacing between bullet and text or its does something else??
if not ,which method is responsible for customizing the spacing between text and bullet?
Hi Sonam,
Please check Paragraph Format and List Format in Specifying Formatting topic. You can use setSpaceAfter to set space between list items and text. You can also use setLineSpacing and setLinceSpacingRule methods to set space between lines. Please check ParagraphFormat class for more details.
Best Regards,
hi,
Hi muhammad
Hi Sonam,
Thanks for your inquiry.
sonam.arora:
My Input word file ,ActualWordfile and expectedWordfile is attahced.
Please help and suggest how to get the expected word file. i.e I want that all level of bulleting should be moved by same level given.How is that possible?
Please use ListLevel.NumberPosition Property to set the position (in points) of the number or bullet for the list level. Please use the following code example to achieve your requirements.
Document doc = new Document(MyDir
- “InputWord.doc”);
List list1 = doc.getLists().get(0);
ListLevel level1 = list1.getListLevels().get(0);
level1.setNumberPosition(18);
level1.setTabPosition(72);
level1.setTrailingCharacter(ListTrailingCharacter.TAB);
List list2 = doc.getLists().get(1);
level1 = list2.getListLevels().get(0);
level1.setNumberPosition(72);
level1.setTabPosition(72);
level1.setTrailingCharacter(ListTrailingCharacter.TAB);
List list3 = doc.getLists().get(2);
level1 = list3.getListLevels().get(0);
level1.setNumberPosition(108);
level1.setTabPosition(72);
level1.setTrailingCharacter(ListTrailingCharacter.TAB);
List list4 = doc.getLists().get(3);
level1 = list4.getListLevels().get(0);
level1.setNumberPosition(108);
level1.setTabPosition(72);
level1.setTrailingCharacter(ListTrailingCharacter.TAB);
doc.updateListLabels();
doc.save(MyDir
+ "Out.docx");
sonam.arora:
getBidi() method of Paragraph format class is not working properly.
This method should throw true when the paragraph has right paragraph in it.
But not working out.
Please use the ParagraphFormat.Alignment property to get or set text alignment for the paragraph. If you still face any issue, please share your input document along with expected output document. We will then provide you more information about your query along with code.
The Font.Bidi property specifies whether the contents of this run shall have right-to-left characteristics. The Bidi property, when on, shall not be used with strongly left-to-right text. Any behavior under that condition is unspecified. This property, when off, shall not be used with strong right-to-left text. Any behavior under that condition is unspecified.
Hi Tahir,
Hi Tahir,
Hi Tahir,
Hi Tahir,
Hi Sonam,
Thanks for your inquiry.
sonam.arora:
But it works only upto three multi levels.As soon as I add one more level and change the code for same as below, the indentation is handle upto list3 only.
Please modify your code as shown below to get the required output.
ListLevel.NumberPosition Property : Returns or sets the position (in points) of the number or bullet for the list level.
ListLevel.TabPosition Property : Returns or sets the tab position (in points) for the list level.
Document doc = new
Document(MyDir + “InputWord-aspose.doc”);
List list1 = doc.getLists().get(0);
ListLevel level1 = list1.getListLevels().get(0);
level1.setNumberPosition(18);
level1.setTabPosition(72);
level1.setTrailingCharacter(ListTrailingCharacter.TAB);
List list2 = doc.getLists().get(1);
level1 = list2.getListLevels().get(0);
level1.setNumberPosition(72);
level1.setTabPosition(72);
level1.setTrailingCharacter(ListTrailingCharacter.TAB);
List list3 = doc.getLists().get(2);
level1 = list3.getListLevels().get(0);
level1.setNumberPosition(108);
level1.setTabPosition(72);
level1.setTrailingCharacter(ListTrailingCharacter.TAB);
List list4 = doc.getLists().get(3);
level1 = list4.getListLevels().get(0);
level1.setNumberPosition(108);
level1.setTabPosition(72);
level1.setTrailingCharacter(ListTrailingCharacter.TAB);
List list5 = doc.getLists().get(4);
level1 = list5.getListLevels().get(0);
level1.setNumberPosition(180);
level1.setTabPosition(72);
level1.setTrailingCharacter(ListTrailingCharacter.TAB);
doc.updateListLabels();
doc.save(MyDir + "Out.docx");
<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-GB</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>AR-SA</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>
<![endif]–>
sonam.arora:
Is there any method throgh which i can get that whether the next paragraph has different bullet than the previos one.
You may use Node.NextSibling property to get the node immediately following this node. If this node is Paragraph node, you can check either it is list item or not. You may use Node.NextPreOrder method to get the next node according to the pre-order tree traversal algorithm.
sonam.arora:
H
However facing below error as I try to get 10th index.
that when below code is added.:
List list11 = doc.getLists().get(10);
level1 = list11.getListLevels().get(0);
level1.setNumberPosition(64);
level1.setTabPosition(90);
Is aspose able to handle indents only upto 9 levels?
A list in a Microsoft Word document is a set of list formatting properties. Each list can have up to 9 levels and formatting properties, such as number style, start value, indent, tab position etc are defined separately for each level.
I am working over your last query and will update you asap.
Hi Sonam,
Thanks for your patience.
sonam.arora:
Atached are my Input ,Output and ExpectedOutputWord file.
How can I customize spacing between bullet and Text???
I have modified your code, please check the following highlighted code below. In your case, I suggest you please use the TabPosition, TextPosition and NumberPosition to get the required output.
Hope this helps you. Please let us know if you have any more queries.
Document doc = new Document(MyDir + "InputWord.docx");
int count = 0;
int i = 0;
int j = 8;
for (Paragraph para : (Iterable<Paragraph>)doc.getChildNodes(NodeType.PARAGRAPH , true))
{
if(para.isListItem())
{
count++;
final int one = 1;
final String ONE = Integer.toString(one);
final String COUNT = Integer.toString(count);
//para.getParagraphFormat().setLeftIndent(0.0);
if (COUNT.equalsIgnoreCase(ONE)){
List list1 = para.getListFormat().getList();
ListLevel level1 = list1.getListLevels().get(0);
level1.setNumberPosition(i);
level1.setTextPosition(i);
level1.setTabPosition(j);
level1.setTrailingCharacter(ListTrailingCharacter.TAB);
i=i+10;
j=j+10;
}
else{
List list0 = para.getListFormat().getList();
ListLevel level0 = list0.getListLevels().get(0);
level0.setNumberPosition(i);
level0.setTextPosition(i);
level0.setTabPosition(j);
level0.setTrailingCharacter(ListTrailingCharacter.TAB);
i=i+10;
//j=j+10;
}
}
}
doc.save(MyDir + "Out.docx");
Hi Tahir,
Hey Tahir,
Hi Sonam,
Thanks for your inquiry.
sonam.arora:
Please suggest how can I use Node.NextSibling method in my code in last query.As in my code I am taking each list as a paragraph and checking whether this is list item.Please suggest below is the code for reference.
In your case, you do not need to use Node.NextSibling. You can get the next paragraph from paragraph collection. See Document.getChildNodes method.
sonam.arora:
But the code provided seems not working.
In my Input file there is a space between bullet and Text .and when Output doc is created the space is still there.
The shared code works fine. There are spaces between bullet and text. Please check the attached image for detail. You can find the empty Run nodes from the list and remove them. See the highlighted code snippet.
Document doc = new Document(MyDir + "Input+-+28May.doc");
int count = 0;
int i = 0;
int j = 8;
for (Paragraph para : (Iterable)doc.getChildNodes(NodeType.PARAGRAPH , true))
{
if(para.isListItem())
{
for (Run run : (Iterable)doc.getChildNodes(NodeType.RUN , true))
{
if(run.toString(SaveFormat.TEXT).trim().isEmpty())
{
run.remove();
}
}
count++;
final int one = 1;
final String ONE = Integer.toString(one);
final String COUNT = Integer.toString(count);
if (COUNT.equalsIgnoreCase(ONE)){
List list1 = para.getListFormat().getList();
ListLevel level1 = list1.getListLevels().get(0);
level1.setNumberPosition(i);
level1.setTextPosition(i);
level1.setTabPosition(j);
level1.setTrailingCharacter(ListTrailingCharacter.TAB);
i=i+10;
j=j+10;
}
else{
List list0 = para.getListFormat().getList();
ListLevel level0 = list0.getListLevels().get(0);
level0.setNumberPosition(i);
level0.setTextPosition(i);
level0.setTabPosition(j);
level0.setTrailingCharacter(ListTrailingCharacter.TAB);
i=i+10;
}
}
}
doc.save(MyDir + "Out.docx");
Hi Tahir,
Hi Sonam,
Please accept my apologies for your inconvenience.
Please use Paragraph.getRuns method as shown in following highlighted code snippet to fix this issue. Please let us know if you still face any issue.
Document doc = new Document(MyDir + "Input+-+28May.doc");
int count = 0;
int i = 0;
int j = 8;
for (Paragraph para : (Iterable<Paragraph>)doc.getChildNodes(NodeType.PARAGRAPH , true))
{
if(para.isListItem())
{
for (Run run : para.getRuns())
{
if(run.toString(SaveFormat.TEXT).trim().isEmpty())
{
run.remove();
}
}
count++;
final int one = 1;
final String ONE = Integer.toString(one);
final String COUNT = Integer.toString(count);
if (COUNT.equalsIgnoreCase(ONE)){
List list1 = para.getListFormat().getList();
ListLevel level1 = list1.getListLevels().get(0);
level1.setNumberPosition(i);
level1.setTextPosition(i);
level1.setTabPosition(j);
level1.setTrailingCharacter(ListTrailingCharacter.TAB);
i=i+10;
j=j+10;
}
else{
List list0 = para.getListFormat().getList();
ListLevel level0 = list0.getListLevels().get(0);
level0.setNumberPosition(i);
level0.setTextPosition(i);
level0.setTabPosition(j);
level0.setTrailingCharacter(ListTrailingCharacter.TAB);
i=i+10;
}
}
}
doc.save(MyDir + "Out.docx");
Hi Tahir,
