Por que a segunda linha da tabela não será gravada? [duplicado]
Esta pergunta já tem uma resposta aqui:
Célula numerada ímpar não adicionada ao PDF 1 respostaEstou tentando criar tabela sem bordas com 4 colunas e 2 linhas em cima do meu documento PDF. O problema é que a segunda linha não será gravada. Este é o meu código:
float[] columnWidths = { 2, 1, 1, 1};
PdfPTable table = new PdfPTable(columnWidths);
table.WidthPercentage = 100;
if (...) //true
{
if (...) //true
{
PdfPCell p = new PdfPCell(new Phrase("AAA:_______________",infoFont));
p.BorderWidth = 0;
table.AddCell(p); // fixed pos. 1st col,1st row
}
if (...) //true
{
PdfPCell p = new PdfPCell(new Phrase("BBB:_____", infoFont));
p.BorderWidth = 0;
table.AddCell(p); // fixed pos. 2nd col,1st row
}
if (...) //true
{
PdfPCell p = new PdfPCell(new Phrase("CCC:_____", infoFont));
p.BorderWidth = 0;
table.AddCell(p); // fixed pos. 3rd col,1st row
}
if (...) //true
{
PdfPCell p = new PdfPCell(new Phrase("DDD:_____", infoFont));
p.BorderWidth = 0;
table.AddCell(p); // fixed pos. 4th col,1st row
}
}
if (...) //true
{
if (...) //true
{
PdfPCell p = new PdfPCell(new Phrase("EEE: " + eee));
p.BorderWidth = 0;
table.AddCell(p); // fixed pos. 1st col,2nd row
}
if (...) //true
{
PdfPCell p = new PdfPCell(new Phrase("FFF: " + fff));
p.BorderWidth = 0;
table.AddCell(p); // fixed pos. 2nd col,2nd row
}
if (...) //true
{
PdfPCell p = new PdfPCell(new Phrase("GGG: " + ggg));
p.BorderWidth = 0;
table.AddCell(p); // fixed pos. 3rd col,2nd row
}
if (...) //true
{
PdfPCell p = new PdfPCell(new Phrase("HHH:___________________"));
p.BorderWidth = 0;
table.AddCell(p); // fixed pos. 4th col,2nd row
}
}
document.Add(table);
Como posso lidar com isso? E a segunda pergunta: posso ter uma posição fixa para todas as condições if (verifique os comentários no código); portanto, quando uma condição if na primeira linha não for verdadeira, essa célula deverá estar vazia?