ItextSharp 4.1.6.PDF 표 - 각 셀 위에 공백을 제거하는 방법은 무엇입니까?[패딩 및 이미 0으로 설정된 선도]
-
12-12-2019 - |
문제
itextsharp의 테이블에 문제가 있습니다.상단 및 하단 패딩없이 세포를 갖고 싶어하므로 서로 가깝게 배치됩니다.
PADDING과 셀의 선행을 0으로 설정했지만 공백은 여전히 남아 있습니다.
누구든지 공백을 제거하는 방법을 알려주십시오
편집 :
Thanx 딜란에서 답변을 즉시 답변하기 위해, 저는이 문제를 해결할 수있었습니다.누군가가 비슷한 문제를 가로 지르는 경우 소스 스 니펫
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
해결책
상단 패딩을 작거나 부정적으로 설정하십시오.또 다른 옵션은입니다
PdfPCell.setUseAscender()
.
ex :
cell.setPaddingTop(0f); // No padding on top cell
.
또는
cell.UseAscender = true;
.
가지고있는 코드를 붙여 넣으십시오.
제휴하지 않습니다 StackOverflow