在两列中的显示数据中的单个行 [英] Display data in two columns in a single row

查看:163
本文介绍了在两列中的显示数据中的单个行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用户数据表containg地址。我使用iTextSharp的将其转换为PDF格式,现在我的要求是我想在另一列一列和其他用户的名称和地址显示一个用户的姓名,地址。只有在一个行,必须有两列,如何使用iTextSharp的做到这一点?

I have a datatable containg address of users. I converted it to PDF using iTextSharp and now my requirement is i want to display one user's name, address in one column and another user's name and address in another column. In one row there must be two columns only, how to do this using iTextSharp?

推荐答案

应该是创造一个PdfPTable对象和配置的宽度,使得每行有2列的只是一个问题。

Should be just a matter of creating a PdfPTable object and configuring the widths such that each row has 2 columns.

http://www.mikesdotnetting.com/Article/86/iTextSharp-引入桌

一个样,我从previous code发(没试过编译它...)

A sample I made from previous code (haven't tried to compile it...)

iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.LETTER, 20, 20, 20, 20);
PdfPTable table;
PdfPCell cell;
iTextSharp.text.Paragraph paragraph;

table = new PdfPTable(2);
paragraph = new Paragraph();
paragraph.Add(new Chunk("TEXT", FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.NORMAL)));
cell = new PdfPCell(paragraph);
cell.BorderWidth = 0;
cell.Padding = 0;
cell.PaddingTop = 12;
cell.HorizontalAlignment = Element.ALIGN_LEFT;
table.AddCell(cell);
cell = new PdfPCell(paragraph);
cell.BorderWidth = 0;
cell.Padding = 0;
cell.PaddingTop = 12;
cell.HorizontalAlignment = Element.ALIGN_LEFT;
table.AddCell(cell);
table.SetWidthPercentage(new float[2] { 460f, 140f }, PageSize.LETTER);
table.HorizontalAlignment = Element.ALIGN_CENTER;
document.Add(table);

这篇关于在两列中的显示数据中的单个行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆