Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ITextSharp full page height layout

I want to create th following PDF layout with ITextSharp:

enter image description here

I use the following code to generate my table:

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();

How can I force table to cover full page height without use fixed height value?

like image 462
danyolgiax Avatar asked Dec 04 '22 07:12

danyolgiax


1 Answers

you can use table.ExtendLastRow = true;

like image 191
VahidN Avatar answered Dec 26 '22 03:12

VahidN