IText学习手册——Chunk移位
默认情况下,多个块是在同一行,底边对其。通过Chunk的SetTextRise方法,将Chunk升高或者降低
/// <summary> /// Chunk移位 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button13_Click(object sender, EventArgs e) { Document doc = new Document(); var writer = PdfWriter.GetInstance(doc, File.Open(path, FileMode.Create)); writer.InitialLeading = 30;//设置每行的间距 doc.Open(); //第一段内容 doc.Add(new Chunk("This is first line")); //设置字体 var font = new iTextSharp.text.Font(BaseFont.CreateFont(), 4, iTextSharp.text.Font.BOLD, BaseColor.RED); var secondChunk = new Chunk("This is second line", font); //向上偏移6个单位 secondChunk.SetTextRise(6); //第二段内容 doc.Add(secondChunk); doc.Close(); }
显示效果: