iTextSharp を使用して PDF を生成しています。
私のコードは、
public FileStreamResult Export(int ID)
{
MemoryStream stream = new MemoryStream();
Document pdf = new Document();
PdfWriter writer = PdfWriter.GetInstance(pdf, stream);
pdf.Open();
//code for table
PdfPTable table = new PdfPTable(3);
PdfPCell cell = new PdfPCell(new Phrase("Header spanning 3 columns"));
cell.Colspan = 3;
cell.HorizontalAlignment = 1;
table.SpacingBefore = 100; //not working
table.SpacingAfter = 10; //not working
table.AddCell(cell);
table.AddCell("Col 1 Row 1");
table.AddCell("Col 2 Row 1");
table.AddCell("Col 3 Row 1");
table.AddCell("Col 1 Row 2");
table.AddCell("Col 2 Row 2");
table.AddCell("Col 3 Row 2");
pdf.Add(table);
pdf.Close();
//code to download
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename="+_child[0].Child_Name+".pdf");
Response.Buffer = true;
Response.Clear();
Response.OutputStream.Write(stream.GetBuffer(), 0, stream.GetBuffer().Length);
Response.OutputStream.Flush();
Response.End();
return new FileStreamResult(Response.OutputStream, "application/pdf");
}
ページの上部にテーブルが表示されます。テーブルを下に移動したいのですが、どうすればよいですか?
助けてください、
ありがとう。