C# iTextSharp-列表()中的多个级别
在iTextSharp中创建嵌套列表很简单C# iTextSharp-列表()中的多个级别,c#,itextsharp,C#,Itextsharp,在iTextSharp中创建嵌套列表很简单 var list = new List(true); list.add("Something here"); list.add("Something else here"); var nestedList = new List(true); nestedList.add("Some other value"); list.add(nestedList); document.add(list); // assuming here of course yo
var list = new List(true);
list.add("Something here");
list.add("Something else here");
var nestedList = new List(true);
nestedList.add("Some other value");
list.add(nestedList);
document.add(list); // assuming here of course you have
// created an instance of Document()!
将产生一些真正基本的东西,例如
1. Parent list item
1.1 Something here
1.2 Something else here
但我看不到API中任何地方有这种可能。我能想到的唯一方法是使用段落()
,但有没有其他人找到了更优雅的解决方案
谢谢我能看到的唯一方法是手动跟踪父嵌套,并使用
PreSymbol
属性进行设置
详情如下:
List list = new List(List.ORDERED, 20f);
list.IndentationLeft = 20f;
// add sublist
List subList = new List(List.ORDERED);
subList.PreSymbol = string.Format("{0}.", i);
subList.Add("Something here");
subList.Add("Something else here");
list.Add(subList);
doc.Add(list);
这将导致:
对不起,这不是我想要的。我知道如何嵌套列表,但我特别想要1.1和1.2。我将更新我的问题以反映这一点。@Matt我已更新我的问题以显示我知道的唯一方式。如果这也不好,请让我知道,我会删除它,因为我的声誉下降。似乎没有办法从api中确定父级,除非我错过了:@hutchoniod这正是我想要的。非常感谢你!