C# 如何在itext7表格单元格中插入换行符

C# 如何在itext7表格单元格中插入换行符,c#,itext7,C#,Itext7,如何在itext7表格单元格中插入换行符? 这是我的密码 PdfWriter writer = new PdfWriter(@"C:\Temp\test123.pdf"); PdfDocument pdf = new PdfDocument(writer); Document document = new Document(pdf, PageSize.LEGAL); string msg = $"This is line 1{Environment.NewLine}This should be

如何在itext7表格单元格中插入换行符? 这是我的密码

PdfWriter writer = new PdfWriter(@"C:\Temp\test123.pdf");
PdfDocument pdf = new PdfDocument(writer);
Document document = new Document(pdf, PageSize.LEGAL);
string msg = $"This is line 1{Environment.NewLine}This should be line 2, However it's not showing";
Table table = new Table(1, true);
Cell cell = new Cell().Add(new Paragraph(msg));
table.AddCell(cell);
document.Add(table);
document.Close();
Process.Start(@"C:\Temp\test123.pdf");

在使用诸如
iText
之类的PDF生成工具时,通常应使用
段落
,而不是手动设置换行符

var cell = new Cell();
cell.Add(new Paragraph("This is line 1");
cell.Add(new Paragraph("This should be line 2, and it is!~");

在使用诸如
iText
之类的PDF生成工具时,通常应使用
段落
,而不是手动设置换行符

var cell = new Cell();
cell.Add(new Paragraph("This is line 1");
cell.Add(new Paragraph("This should be line 2, and it is!~");

试着插入多个
段落
你应该在@zcui93处给出答案,因为这确实是解决方案。你应该在@zcui93处给出答案,因为这确实是解决方案正版iText开发者的答案:)@BrunoLowagieYes,我感谢你的回答。我投了赞成票。试着插入多个
段落
,你应该在@zcui93给出答案,因为这确实是解决方案。你应该在@zcui93给出答案,因为这确实是解决方案。正版iText开发者看起来:)@BrunoLowagieYes,我感谢你的回答。我投了弃权票。