2017-12-21 5 views
0

itext7テーブルセルに改行を挿入するにはどうすればよいですか? iTextのようなPDF生成ツールを使用するときは、一般的に手動で設定改行をParagraph代わりにを使用する必要があります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"); 
+1

ことは確かなソリューションですので、あなたはzcui93 @その答えをする必要があり、複数の 'Paragraph' – zcui93

+0

を挿入する代わりに試してみてください。 –

+0

それは本当に解決策だから、答えを@ zcui93にする必要があります。 –

答えて

2

は、ここでは、私のコードです。

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