我使用iTextSharp在我的应用程序中创建PDF。然而,我必须重新创建一个表,在那里我必须设置一个非常小的列的大小。下面是显示要设置列的大小的图片:

当表创建的其余部分都正常时,我无法设置这个宽度。
代码:
PdfPTable table = new PdfPTable(2);
table.WidthPercentage = 82.0f;
PdfPCell cell = new PdfPCell(new Phrase("Com a assinatura autógrafa, o signatário desta Auto-declaração garante ter cumprido estas condições:", fontetexto));
cell.PaddingBottom = 10f;
cell.PaddingTop = 10f;
cell.Colspan = 2;
cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
table.AddCell(cell);
table.AddCell("1. ");
table.AddCell("Os óleos e gorduras vegetais velhos fornecidos são biomassa conforme o Decreto de biomassa.");发布于 2014-02-28 11:47:58
尝试使用以下代码
PdfPTable table = new PdfPTable(new float[] { 30f, 400f });
table.HorizontalAlignment = 0;
table.TotalWidth = 500f;
table.LockedWidth = true;
table.SetWidths(widths);发布于 2014-02-28 12:24:08
如果您使用XmlParser而不是普通的HtmlParser,您可以用更少的努力就可以做到这一点。
var document = new Document();
var workStream = new MemoryStream(); // or you can use fileStream also.
PdfWriter writer = PdfWriter.GetInstance(document, workStream);
XMLWorkerHelper.GetInstance().ParseXHtml(writer, document, stream, Encoding.UTF8);看看这个nuget MvcRazorToPdf,我发现这个比RazorPDF更好
发布于 2014-09-03 13:19:34
以下代码适用于我:
PdfPTable table = new PdfPTable(2);
table.TotalWidth = 500;
table.SetTotalWidth(new float[] { 30f, 400f });
PdfPCell c1 = new PdfPCell();
PdfPCell c2 = new PdfPCell();
c1.AddElement(new Phrase("first column"));
c1.AddElement(new Phrase("second column"));
table.Rows.Add(new PdfPRow(new PdfPCell[] { c1, c2 }));https://stackoverflow.com/questions/22094190
复制相似问题