IText学习手册——画点线
通过实例化DottedLineSeparator,并将其加入文档中,实现画点线。
DottedLineSeparator继承自LineSeparator,特殊的是可以设置Gap属性,设定点与点之间的宽度。
/// <summary> /// 画点线 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button21_Click(object sender, EventArgs e) { DottedLineSeparator line = new DottedLineSeparator(); //下移5个单位 line.Offset = -5; //设置点之间的距离 line.Gap = 20; Document doc = new Document(); PdfWriter.GetInstance(doc, File.Open(path, FileMode.Create)); doc.Open(); Paragraph paragraph = new Paragraph(); doc.Add(new Paragraph("This is first paragraph")); doc.Add(line); doc.Add(new Paragraph("This is second paragraph")); doc.Close(); }
显示效果: