IText学习手册——使用Chunk实现导航
Chunk对象的3个方法:
1.setLocalDestination();定义导航点
2.setLocalGoto();跳转到导航点
3.setRemoteGoto();跳转到外部网页
/// <summary> /// 使用Chunk实现导航 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button23_Click(object sender, EventArgs e) { Document doc = new Document(); PdfWriter.GetInstance(doc, File.Open(path, FileMode.Create)); doc.Open(); Chunk top = new Chunk("This is top"); top.SetLocalDestination("Top"); Paragraph topParagraph = new Paragraph(top); doc.Add(topParagraph); for (var i = 0; i < 100; i++) { doc.Add(new Paragraph("This is " + (i + 1) + "line")); } Chunk goTop = new Chunk("Go to top"); goTop.SetLocalGoto("Top"); Paragraph bottomParagraph = new Paragraph(goTop); doc.Add(bottomParagraph); doc.Close(); }
显示效果: