我是 iTextSharp 的初学者,我编写此代码以将 RoundRectangle 创建到 PdfPTable 并在页面中心对齐表格
string pdfpath = Server.MapPath("PDFs");
RoundRectangle rr = new RoundRectangle();
using (Document document = new Document())
{
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(pdfpath + "/Graphics6.pdf", FileMode.CreateNew));
document.Open();
PdfPTable table = new PdfPTable(1);
float[] f=new float[]{0.5f};
table.SetWidths(f);
PdfPCell cell = new PdfPCell()
{
CellEvent = rr,
Border = PdfPCell.NO_BORDER,
Phrase = new Phrase("test")
};
table.AddCell(cell);
document.Add(table);
我想改变表格宽度我改变代码
string pdfpath = Server.MapPath("PDFs");
RoundRectangle rr = new RoundRectangle();
using (Document document = new Document())
{
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(pdfpath + "/Graphics6.pdf", FileMode.CreateNew));
document.Open();
PdfPTable table = new PdfPTable(1);
table.TotalWidth = 5;
int[] w = new int[] { 12};
table.SetWidths(w);
PdfPCell cell = new PdfPCell()
{
CellEvent = rr,
Border = PdfPCell.NO_BORDER,
Phrase = new Phrase("test")
};
table.AddCell(cell);
document.Add(table);
但没有工作,也没有改变页面中的宽度表。请帮我。谢谢大家