我的问题是itext不会为长表添加新页面,它仅呈现一页并且仅显示表的一部分,这是我的代码:
MemoryStream reportStream = new MemoryStream();
IEnumerable<Site> siteList = SiteManager.GetAllSites();
Document doc = new Document();
doc.SetMargins(7f, 10f, 10f, 7f);
var writer = PdfWriter.GetInstance(doc, reportStream);
writer.CloseStream = false;
doc.Open();
PdfPTable tableLayout = new PdfPTable(11);
var personalTable = AddPersonalTable(tableLayout);
personalTable.WriteSelectedRows(0, -1, 0, 842, doc.Left, doc.Top
,writer.DirectContent);
doc.Close();
byte[] byteInfo = reportStream.ToArray();
reportStream.Write(byteInfo, 0, byteInfo.Length);
reportStream.Position = 0;
return reportStream;
和我的方法:
private static PdfPTable AddPersonalTable(PdfPTable tableLayout)
{
float[] headers = { 12, 9, 10, 4, 9, 11, 9, 9, 9, 9, 9 };
tableLayout.SetWidths(headers);
tableLayout.WidthPercentage = 100;
tableLayout.HeaderRows = 1;
//adding cells
return tableLayout;
}
感谢您的帮助。