Itextsharp序列号下方的下一行

时间:2013-07-12 08:15:10

标签: asp.net asp.net-mvc-3 itextsharp

Image from PDf我正致力于使用iTextSharp生成PDF。在给出序列号后,我会在页面上写下一些注释。我正在使用Paragraph。但是段落中的下一行正好在序列号下面。如果它到下一行,我怎么才能将边距或填充定义为段落?

我的代码

for(int i=0;i<list.count;i++)
{
    doc.Add(new Paragraph(String.Format("{0}) {1} ({2}).", (i + 1).ToString(), "Here Goes My String", "Date Time"), font));
}

i是序列号。

1 个答案:

答案 0 :(得分:0)

而是将列表项添加到段落中,创建itextsharp的List项并将其添加到listItem的Arraylist中。您可以创建有序和无序列表项,类似于HTML对应<ul><ol>

检查以下代码:

  iTextSharp.text.List list = new iTextSharp.text.List(iTextSharp.text.List.ORDERED, 20f);
  list.IndentationLeft = 20f;//indented 20 points from left margin
  list.Add("The RomanList is added to the ordered list, and iTextSharp indents the RomanList relative to the ordered list to which it belongs");
  list.Add("The RomanList is added to the ordered list, and iTextSharp indents the RomanList relative to the ordered list to which it belongs");
  list.Add("Three");
  pdfDoc.Add(list);//add list to document

上面的代码将创建有序列表。第二个参数将symbolIndent设置为20个点,这会导致数字与项目本身之间的空格。

要了解有关使用Itextsharp创建列表的更多信息,请查看以下链接:

http://www.mikesdotnetting.com/Article/83/Lists-with-iTextSharp

相关问题