通过Chunk的SetBackground方法,定义背景色

/// <summary>
        /// Chunk背景色
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button12_Click(object sender, EventArgs e)
        {
            Document doc = new Document();
            PdfWriter.GetInstance(doc, File.Open(path, FileMode.Create));
            doc.Open();
            var chunk = new Chunk("This is Chunk");

            //设置背景色
            chunk.SetBackground(BaseColor.YELLOW);


            //在pdf文档中使用chunk输出内容
            doc.Add(chunk);
            doc.Close();
        }

显示效果:

IText学习手册——Chunk背景色

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-18
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案