IText学习手册——通过Phrase输出内容
Phrase是多个Chunk的集合,默认设置了行间距(Leading),当然,也可以手动修改:
/// <summary> /// 使用Phrase输出内容 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button14_Click(object sender, EventArgs e) { Document doc = new Document(); PdfWriter.GetInstance(doc, File.Open(path, FileMode.Create)); doc.Open(); var phrase = new Phrase(); //设置行间距,默认为1.5倍 phrase.Leading = 30; //这种phrase的内容 phrase.Add(new Chunk("This is frist chunk")); phrase.Add(Chunk.NEWLINE); phrase.Add(new Chunk("This is second chunk")); doc.Add(phrase); doc.Close(); }
显示效果: