Hello,
Hi,
Hi,
Hi,
ChildItem1 desc
Dear Mr Hafeez,
As a matter of fact, I've asked how can I know that suitable value for the margin left attribute. Is it possible to reach by using listLevelNumber stuff? Is there a ration between them?
brgds
Hi,
NodeCollection paragraphs = doc.getChildNodes(NodeType.PARAGRAPH, true);
for (Paragraph para : (Iterable<Paragraph>)paragraphs)
{
if (para.isListItem())
{
System.out.println(para.getParagraphFormat().getLeftIndent());
}
}
Thank you for your politely assistance we will be try acc to this info.
Hi again Mr Hafeez,
I applied your solution. could you plz see my code snippet below:
private void docCreate(DocumentItem item, DocumentBuilder builder, boolean isLast)
{
try
{
com.aspose.words.List tempList = builder.getListFormat().getList();
int level = builder.getListFormat().getListLevelNumber();
builder.setBold(true);
builder.writeln(item.getItemName());
if (!StringUtility.isNullOrEmpty(item.getContent()))
{
builder.setBold(false);
double f = builder.getCurrentParagraph().getParagraphFormat().getLeftIndent();
System.out.println(f);
builder.getListFormat().removeNumbers();
builder.insertHtml(setIndentation(item.getContent(), f));
builder.getListFormat().setList(tempList);
builder.getListFormat().setListLevelNumber(level);
}
if (isLast)
builder.getListFormat().removeNumbers();
}
catch (Exception e)
{
e.printStackTrace();
}
}
private String setIndentation(String content, double level)
{
//level *= 25;
content = content.replaceAll("
", "");
content = content.replaceAll("
return "
" + content + "
";}
But, it does not make supply the exactly right alignment. i.e. when returns 18.0, essentially it must be return 25.0. I attached the out file for your consideration, you may want to take a look at page 2.
Best regards.
Hi Mustafa,
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);builder.getListFormat().setList(doc.getLists().add(ListTemplate.NUMBER_ARABIC_DOT));
for (int i = 0; i < 9; i++) {
builder.getListFormat().setListLevelNumber(i);
builder.writeln("Level " + i);
}HandleNodeChanging_ListIndent hanlder = new HandleNodeChanging_ListIndent();
doc.setNodeChangingCallback(hanlder);NodeCollection paragraphs = doc.getChildNodes(NodeType.PARAGRAPH, true);
for (Paragraph paragraph : (Iterable<Paragraph>) paragraphs) {
if (paragraph.isListItem()) {
builder.moveTo(paragraph);
hanlder.leftIndent = paragraph.getParagraphFormat().getLeftIndent();builder<font color="BLUE"><b>.</b></font>insertHtml<font color="BLUE"><b>(</b></font><font color="PURPLE">"<p>ChildItem1 desc</p>"</font><font color="BLUE"><b>)</b></font><font color="BLUE"><b>;</b></font> <font color="BLUE"><b>}</b></font>
}
builder.getDocument().save(“C:\Temp\Out.doc”);
static class HandleNodeChanging_ListIndent implements INodeChangingCallback {
public double leftIndent = 0.0;<font color="RED"><b>public</b></font> <font color="RED"><b>void</b></font> nodeInserted<font color="BLUE"><b>(</b></font>NodeChangingArgs args<font color="BLUE"><b>)</b></font> <font color="RED"><b>throws</b></font> Exception <font color="BLUE"><b>{</b></font> <font color="RED"><b>if</b></font> <font color="BLUE"><b>(</b></font>args<font color="BLUE"><b>.</b></font>getNode<font color="BLUE"><b>(</b></font><font color="BLUE"><b>)</b></font><font color="BLUE"><b>.</b></font>getNodeType<font color="BLUE"><b>(</b></font><font color="BLUE"><b>)</b></font> <font color="BLUE">=</font><font color="BLUE">=</font> NodeType<font color="BLUE"><b>.</b></font>RUN<font color="BLUE"><b>)</b></font> <font color="BLUE"><b>{</b></font> Run run <font color="BLUE">=</font> <font color="BLUE"><b>(</b></font><font color="BLUE"><b>(</b></font>Run<font color="BLUE"><b>)</b></font> args<font color="BLUE"><b>.</b></font>getNode<font color="BLUE"><b>(</b></font><font color="BLUE"><b>)</b></font><font color="BLUE"><b>)</b></font><font color="BLUE"><b>;</b></font> Paragraph para <font color="BLUE">=</font> run<font color="BLUE"><b>.</b></font>getParentParagraph<font color="BLUE"><b>(</b></font><font color="BLUE"><b>)</b></font><font color="BLUE"><b>;</b></font>
para.getParagraphFormat().setLeftIndent(leftIndent);
<font color="BLUE"><b>}</b></font> <font color="BLUE"><b>}</b></font> <font color="RED"><b>public</b></font> <font color="RED"><b>void</b></font> nodeInserting<font color="BLUE"><b>(</b></font>NodeChangingArgs args<font color="BLUE"><b>)</b></font> <font color="RED"><b>throws</b></font> Exception <font color="BLUE"><b>{</b></font> <font color="GREEN"><i>// Do Nothing
}
<font color="RED"><b>public</b></font> <font color="RED"><b>void</b></font> nodeRemoved<font color="BLUE"><b>(</b></font>NodeChangingArgs args<font color="BLUE"><b>)</b></font> <font color="RED"><b>throws</b></font> Exception <font color="BLUE"><b>{</b></font> <font color="GREEN"><i>// Do Nothing
}
<font color="RED"><b>public</b></font> <font color="RED"><b>void</b></font> nodeRemoving<font color="BLUE"><b>(</b></font>NodeChangingArgs args<font color="BLUE"><b>)</b></font> <font color="RED"><b>throws</b></font> Exception <font color="BLUE"><b>{</b></font> <font color="GREEN"><i>// Do Nothing
}
}