Itextsharp Alignments

时间:2015-02-08 10:29:52

标签: c# .net itextsharp

我正在开展一个应该生成组织良好的报告的项目。我想得到这样的输出;

 Reference No    : mp010
 Applied Vacancy : Helper
 ID No           : 200882318

但是目前我得到的输出没有所需的对齐。 例如;

 Reference No : mp010
 Applied Vacancy : Helper
 ID No : 200882318

我使用 chunks 来打印获取输出。 "其他"表示字体类型。

      Chunk refn = new Chunk("Reference No : " + refr + "", other);                       
      Chunk positn = new Chunk("Applied Vacancy : " + position + "", other);
      Chunk idno = new Chunk("ID No : " + id + "", other);

我对itextsharp很新,这是我的第一份报告。请帮帮我......

1 个答案:

答案 0 :(得分:0)

这是使用PdfPTable

实现此目标的示例
PdfPTable third_table = new PdfPTable(2);
third_table.TotalWidth = 560f;
third_table.LockedWidth = true;
third_table.SetWidths(new float[] { 2.4f, 6.6f });

third_table.AddCell(new PdfPCell(new Phrase("Responsibilities Held: ", other)) { BorderWidth = 0 });
third_table.AddCell(new PdfPCell(new Phrase( Responsibilities_held, other)) { BorderWidth = 0 });

third_table.AddCell(new PdfPCell(new Phrase("Description of Work Done:", other)) { BorderWidth = 0 });
third_table.AddCell(new PdfPCell(new Phrase( Description_of_work_done, other)) { BorderWidth = 0 });

document.Add(third_table);

您可以找到有关PdfPTable herehere的更多信息。