Cell width PdfPTable iTextShar MVC 4

1

I'm using iTextSharp to create PDF's in my application. However I have to recreate a table, where I have to set the size to the one greatly reduced column. Here's the image that shows the size I want to set up the column:

Whentherestofthetablecreationisfine,Icannotreallysetthiswidth.

Code:

PdfPTabletable=newPdfPTable(2);table.WidthPercentage=82.0f;PdfPCellcell=newPdfPCell(newPhrase("Com a assinatura autógrafa, o signatário desta Auto-declaração garante ter cumprido estas condições:", fontetexto));
cell.PaddingBottom = 10f;
cell.PaddingTop = 10f;
cell.Colspan = 2;
cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
table.AddCell(cell);
table.AddCell("1. ");
table.AddCell("Os óleos e gorduras vegetais velhos fornecidos são biomassa conforme o Decreto de biomassa.");
    
asked by anonymous 28.02.2014 / 11:54

1 answer

1

Problem solved. I saw several solutions on the net where they said to set the table as follows:

PdfPTable table = new PdfPTable(10);
table.HorizontalAlignment = 0;
table.TotalWidth = 500f;
table.LockedWidth = true;
float[] widths = new float[] { 100f, 4000f };
table.SetWidths(widths);

The result was always: 'Corrupted file'. The solution then went on to define the size of the table (the array float ) as soon as it was created:

PdfPTable table = new PdfPTable(new float[] { 30f, 400f });
    
28.02.2014 / 13:09