我正在使用 iText 7 创建一个列表。我需要有多个级别的缩进。
例子:
- 项目 1
- 子项 1
- 子项目 2
- 子子项 1
- 子子项目2
- 第 2 项
- 子项 1
- 子项目 2
- 子子项 1
- 子子项目 2 - 子项目 1
- 子项目 2
- 子子项 1
- 子子项目2
- 第 3 项
- 子项 1
- 子项目 2
- 子子项 1
- 子子项目2
当前尝试:
public void IndentedList() throws IOException {
String filePath = dest + "Example2.pdf";
File file = new File(filePath);
file.getParentFile().mkdirs();
PdfWriter writer = new PdfWriter(filePath);
PdfDocument pdf = new PdfDocument(writer);
Document document = new Document(pdf);
PdfFont font = PdfFontFactory.createFont(FontConstants.TIMES_ROMAN);
document.add(new Paragraph("iText is: ").setFont(font));
List list = new List()
.setSymbolIndent(12)
.setListSymbol("\u2022")
.setFont(font);
list
.add(new ListItem("Item 1"))
.add(new ListItem("SubItem1"))
.add(new ListItem("Sub Sub Item 1"))
.add(new ListItem("Sub Sub Item 2"));
.add(new ListItem("Item 1"))
.add(new ListItem("SubItem1"))
.add(new ListItem("Sub Sub Item 1"))
.add(new ListItem("Sub Sub Item 2"));
document.add(list);
document.close();
}
我在想应该有一种方法可以以某种方式缩进特定的列表项。
提前致谢。