【发布时间】:2020-03-08 05:53:10
【问题描述】:
我想增加 itextsharp pdf 创建中第一列矩阵的宽度 图片显示了我想要的 enter image description here
PdfPTable pdfTable = new PdfPTable(dataGridView4.ColumnCount);
//pdfTable. = 5;
pdfTable.DefaultCell.Padding = 3;
pdfTable.DefaultCell.HorizontalAlignment = 0;
pdfTable.HorizontalAlignment = Element.ALIGN_LEFT;
pdfTable.WidthPercentage = 100;
// pdfTable.SetWidths(GetHeaderWidths(font.GetFont("ARIAL", 30), headers));
pdfTable.DefaultCell.VerticalAlignment = Element.ALIGN_CENTER;
pdfTable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
//pdfTa = Element.ALIGN_MIDDLE;
pdfTable.DefaultCell.BorderWidth = 1;
//pdfTable.DefaultCell.Width = 10;(
//pdfTable.TotalWidth = 300;
pdfTable.DefaultCell.UseAscender = true;
iTextSharp.text.Font fon = FontFactory.GetFont("ARIAL", 30);
foreach (DataGridViewColumn column in dataGridView4.Columns)
{
int c = 0;
PdfPCell cell = new PdfPCell(new Phrase(column.HeaderText));
if (c == 0)
{
// pdfTable.SetWidths(c);
// column.HeaderText = "330";
// dataGridView4.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
// pdfTable.AddCell(cell);
}
【问题讨论】:
标签: c# pdf datagridview itext