gpt4 book ai didi

c# - 如何使用 itextsharp 在表格行后创建一个空格?

转载 作者:太空宇宙 更新时间:2023-11-03 19:09:58 26 4
gpt4 key购买 nike

我有一个非常简单的 itextsharp 表,如下所示:

PdfPTable table = new PdfPTable(3);
PdfPCell cell = new PdfPCell(new Phrase("Header spanning 3 columns"));
cell.Colspan = 3;
cell.HorizontalAlignment = 1;
table.AddCell(cell);
table.AddCell("Col 1 Row 1");
table.AddCell("Col 2 Row 1");
table.AddCell("Col 3 Row 1");

// Create spacing after row here only.

table.AddCell("Col 1 Row 2");
table.AddCell("Col 2 Row 2");
table.AddCell("Col 3 Row 2");
doc.Add(table);

如何只在第 1 行和第 2 行之间创建一个空格?

谢谢。

最佳答案

如果你想添加空白行,请按我的理解:试试这个:

PdfPTable table = new PdfPTable(3);
PdfPCell cell = new PdfPCell(new Phrase("Header spanning 3 columns"));
cell.Colspan = 3;
cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
table.AddCell(cell);
table.AddCell("Col 1 Row 1");
table.AddCell("Col 2 Row 1");
table.AddCell("Col 3 Row 1");

PdfPCell cellBlankRow = new PdfPCell(new Phrase(" "));
cell.Colspan = 3;
cell.HorizontalAlignment = 1;
table.AddCell(cellBlankRow);
table.AddCell("");
table.AddCell("");

table.AddCell("Col 1 Row 2");
table.AddCell("Col 2 Row 2");
table.AddCell("Col 3 Row 2");

只需使用 Phrase 插入空白行。我已经测试过并且工作正常..!如果我误解了请告诉我..!

关于c# - 如何使用 itextsharp 在表格行后创建一个空格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21544456/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com