c# - ITextSharp 整页高度布局

标签 c# .net itextsharp

我想用 ITextSharp 创建以下 PDF 布局:

enter image description here

我使用以下代码生成我的表格:

Document document = new Document(PageSize.A4);
MemoryStream memoryStream = new MemoryStream();

PdfWriter writer = PdfWriter.GetInstance(document, memoryStream);

document.Open();

PdfPCell cell;
PdfPTable table = new PdfPTable(2);

table.SetWidths(new float[] { 450, 100 });
table.WidthPercentage = 100;

cell = new PdfPCell(new Phrase("Item cod werwerwer"));
table.AddCell(cell);

cell = new PdfPCell(new Phrase("100"));
table.AddCell(cell);

cell = new PdfPCell(new Phrase(string.Empty));
table.AddCell(cell);

cell = new PdfPCell(new Phrase("100"));
table.AddCell(cell);

document.Add(table);

writer.CloseStream = false;
document.Close();
memoryStream.Position = 0;

return memoryStream.ToArray();

如何在不使用固定高度值的情况下强制表格覆盖整个页面高度?

最佳答案

你可以使用 table.ExtendLastRow = true;

关于c# - ITextSharp 整页高度布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6672025/

相关文章:

c# - 以下哪项是更正确的 INotifyPropertyChanged 实现?

c# - ASP.NET MVC 返回不同的 View

.net - 我可以从 SqlDataAdapter 获取 SqlConnection 吗?

.net - ReactiveUi:绑定(bind)到 ReactiveAsyncCommand 的按钮在使用一次后被禁用

c# - ASCIIEncoding 在 Windows 8 Store 应用程序中不支持

c# - 如何使用 C# 从 PDF 读取自定义字段(不是 XMP 元数据)?

c# - iTextSharp 使用 Response 生成损坏的 PDF

c# - 如何在 c# 中使用 iTextsharp 指定表格在 pdf 文件中的位置

c# - 如何使用 ASP.NET 技术检查请求是否来自本地主机

pdf - 从我的 ActiveX 中禁用 Adob​​e Reader 工具栏