pdfpCell.Rowspan in itextsharp not work properly

故事扮演 提交于 2020-01-07 07:37:08

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!