ITextSharp 4.1.6.Tabela PDF - como remover espaços em branco no topo de cada célula?[preenchimento e entrelinha já definidos como 0]

StackOverflow https://stackoverflow.com//questions/9672046

  •  12-12-2019
  •  | 
  •  

Pergunta

Estou tendo um problema com as tabelas do ITextSharp.Gostaria de ter células sem preenchimento superior e inferior, para que fiquem mais próximas umas das outras.

Embora eu tenha definido o preenchimento e o início da célula como 0, o espaço em branco ainda permanece.

See the screen

Alguém sabe como remover o espaço em branco?

EDITAR:

Obrigado pela resposta imediata de Dylan, consegui resolver meu problema.Aqui está o trecho de origem se alguém se deparar com um problema semelhante

        Document document = new Document(PageSize.A4, 5, 5, 10, 10);
        using (FileStream fs = new FileStream("C:\\Users\\brum\\Desktop\\untitled.pdf", FileMode.Create))
        {
            iTextSharp.text.pdf.PdfWriter.GetInstance(document, fs);
            document.Open();
            PdfPTable table = new PdfPTable(2);
            PdfPCell cell = new PdfPCell(new Phrase("Spanning 2 cols"));

            cell.Colspan = 2;
            cell.HorizontalAlignment = 1;
            cell.Padding = 0f;
            cell.UseAscender = true;
            table.AddCell(cell);

            table.AddCell("Next row 1");
            table.AddCell("Next row 2");

            document.Add(table);
            document.Close();
        }

cell.UseAscender = true; // This is the line that did the trick for me

Foi útil?

Solução

Defina o preenchimento superior para algo pequeno ou até negativo.Outra opção éPdfPCell.setUseAscender().

ex:

cell.setPaddingTop(0f);  // No padding on top cell

ou

cell.UseAscender = true;

Por favor, cole o código que você possui.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top