iTextSharp
c#でasp.net 2010を使用してpdfテーブルの高さを設定できません。セルの固定高さを 15 に設定すると、セルのデータは表示されません。この場合、セルはデータなしで表示されます。セルの高さを15px未満に変更し、セルにもデータを表示したい。
private void CreatePDF()
{
string timestamp = DateTime.Now.ToString("MMddyyyy.HHmmss");
string pdfFileName = Request.PhysicalApplicationPath + "\\Files\\" + "PDFCreation_Reporting_" + timestamp + ".pdf";
Document myDocument = new Document(PageSize.A4, 5, 20, 50, 25);
PdfWriter.GetInstance(myDocument, new FileStream(pdfFileName, FileMode.Create));
myDocument.Open();
PdfPTable UpperTable1 = new PdfPTable(3);
PdfPTable UpperTable2 = new PdfPTable(3);
PdfPCell utcell1 = new PdfPCell();
PdfPCell utcell2 = new PdfPCell();
PdfPCell utcell3 = new PdfPCell();
PdfPCell utcell4 = new PdfPCell();
PdfPCell utcell5 = new PdfPCell();
PdfPCell utcell6 = new PdfPCell();
utcell1.FixedHeight = 15f;
utcell2.FixedHeight = 15f;
utcell3.FixedHeight = 15f;
utcell1.Padding = 0;
utcell2.Padding = 0;
utcell3.Padding = 0;
utcell4.FixedHeight = 15f;
utcell5.FixedHeight = 15f;
utcell6.FixedHeight = 15f;
utcell4.Padding = 0;
utcell5.Padding = 0;
utcell6.Padding = 0;
float[] colWidthsut1 = { 800, 685, 800 };//35%,30%,35% [2285]
UpperTable1.SetWidths(colWidthsut1);
UpperTable1.WidthPercentage = 100;
float[] colWidthsut2 = { 457, 1028, 800 };//20%,45%,35% [2285]
UpperTable2.SetWidths(colWidthsut2);
UpperTable2.WidthPercentage = 100;
string strTest1 = "Test data";
string strTest2 = "Test data";
string strTest3 = "Test Data";
string strTest4 = "Test data";
string strTest5 = "";
string strTest6 = "";
Phrase phrTest1 = new Phrase();
Phrase phrTest2 = new Phrase();
Phrase phrTest3 = new Phrase();
Phrase phrTest4 = new Phrase();
Phrase phrTest5 = new Phrase();
Phrase phrTest6 = new Phrase();
phrTest1.Font = new Font(Font.FontFamily.TIMES_ROMAN, 6, Font.NORMAL, BaseColor.BLACK);
phrTest2.Font = new Font(Font.FontFamily.TIMES_ROMAN, 6, Font.NORMAL, BaseColor.BLACK);
phrTest3.Font = new Font(Font.FontFamily.TIMES_ROMAN, 6, Font.NORMAL, BaseColor.BLACK);
phrTest4.Font = new Font(Font.FontFamily.TIMES_ROMAN, 6, Font.NORMAL, BaseColor.BLACK);
phrTest1.Add(strTest1);
phrTest2.Add(strTest2);
phrTest3.Add(strTest3);
phrTest4.Add(strTest4);
phrTest5.Add(strTest5);
phrTest6.Add(strTest6);
utcell1.AddElement(phrTest1);
utcell2.AddElement(phrTest2);
utcell3.AddElement(phrTest3);
utcell4.AddElement(phrTest4);
utcell5.AddElement(phrTest5);
utcell6.AddElement(phrTest6);
PdfPCell[] firstrowCells = { utcell1, utcell2, utcell3 };
PdfPRow row1 = new PdfPRow(firstrowCells);
UpperTable1.Rows.Add(row1);
PdfPCell[] secondrowCells = { utcell4, utcell5, utcell6 };
PdfPRow row2 = new PdfPRow(secondrowCells);
UpperTable2.Rows.Add(row2);
myDocument.Add(UpperTable1);
myDocument.Add(UpperTable2);
myDocument.Close();
}