Adding a New Line in iTextSharp

后端 未结 10 1668
伪装坚强ぢ
伪装坚强ぢ 2021-02-19 00:36

I’ve been trying to solve this problem for a while now to no avail. I have some text in iTextSharp I’m trying to put on a newline. I’ve tried using the \\n escape c

10条回答
  •  失恋的感觉
    2021-02-19 01:26

    I know this is a little old, but there is yet another way. Here is a little from one report I used.

                var contents = new Paragraph();
                contents.Alignment = Element.ALIGN_CENTER;
    
                contents.Add(new Chunk(string.Format("{0} {1}\n", emp.FirstName, emp.LastName), new Font(baseFont, 11f, Font.BOLD)));
                contents.Add(new Chunk(string.Format("Dept: {0}\n", emp.Departments.Title), new Font(baseFont, 9f)));
                contents.Add(new Chunk(string.Format("Wk Ending:  {0}\n", _date), new Font(baseFont, 9f)));
    

    As you can see, what i did was create chunks. This allows you use to use "\n" to preform line breaks.

提交回复
热议问题