问题
I need to crate a PDF with following structure!
http://www.freeimagehosting.net/6auu8 (link of my image)
my snippet was...
//Create new Pdfptable
PdfPTable table = new PdfPTable(4);
// create new cell
PdfPCell LEFT= new PdfPCell(new Phrase("Left"));
LEFT.Colspan = 1;
LEFT.Rowspan = 2;
table.AddCell(LEFT);
// create another cell
PdfPCell RIGHT= new PdfPCell(new Phrase("Right"));
RIGHT.Colspan = 3;
RIGHT.Rowspan = 2;
table.AddCell(RIGHT);
but, it not working.....
回答1:
Try this:
Document document = new Document();
PdfWriter.GetInstance(document, new FileStream("c:\\Chap0501.pdf", FileMode.Create));
PdfPTable table = new PdfPTable(4);
document.Open();
PdfPCell LEFT = new PdfPCell(new Phrase("Left"));
LEFT.Colspan = 1;
LEFT.Rowspan = 2;
table.AddCell(LEFT);
PdfPCell RIGHT = new PdfPCell(new Phrase("Right"));
RIGHT.Colspan = 3;
RIGHT.Rowspan = 2;
table.AddCell(RIGHT);
document.Add(table);
document.Close();
来源:https://stackoverflow.com/questions/9124504/pdfpcell-rowspan-in-itextsharp-not-work-properly