iTextSharp を使用してテーブルを使用して PDF を作成するコードがありますが、そのテーブルに幅を設定すると、ドキュメントにページがないという例外がスローされます。なぜですか??
これは私のコードの一部です:
using (var document = new Document(PageSize.A4))
{
PdfWriter.GetInstance(document, new FileStream(string.Format("{0}{1}_test.pdf", outputPath, id), FileMode.Create));
document.Open();
//If add this line the exception is the same
//document.NewPage();
PdfPTable table = new PdfPTable(9);
table.TotalWidth = 500f;
float[] widths = new float[] { 20f, 60f, 60f, 30f, 50f, 80f, 50f, 50f, 50f, 50f };
//if this line is commented (table.SetWidths), the PDF works fine.
table.SetWidths(widths);
.....
}