我需要拆分一个包含很多列的大pdfptable,我使用WriteSelectedRows,但是我的pdf上没有表格。
当我删除WriteSelectedRows方法,并在pdf上打印完整表格时,一切正常。
我想念一下吗?
string imageFilePath = Server.MapPath(".") + "/images/test.jpg";
iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(imageFilePath);
Document pdfDucment = new Document(new Rectangle(288f, 144f), 10, 10, 10, 10);
pdfDucment.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());
pdfDucment.SetMargins(50f, 30f, 30f, 30f);
jpg.ScaleToFit(2300, 530);
jpg.Alignment = iTextSharp.text.Image.UNDERLYING;
jpg.SetAbsolutePosition(0, 69);
PdfWriter writerx = PdfWriter.GetInstance(pdfDucment, Response.OutputStream);
StringWriter sw = new StringWriter();
HtmlTextWriter writer = new HtmlTextWriter(sw);
pdfDucment.Open();
pdfTable.TotalWidth = 100;
pdfTable.WriteSelectedRows(0, pdfTable.Rows.Count, 0, 0, writerx.DirectContent);
pdfDucment.Add(para);
pdfDucment.Add(jpg);
pdfDucment.Add(para4);
// pdfDucment.Add(pdfTable);
pdfDucment.Add(para4);
pdfDucment.Add(para2);
pdfDucment.Add(para3);
pdfDucment.Close();
Response.ContentType = "application/pdf";
Response.AppendHeader("content-disposition", "attachment;filename=Prijzen.pdf");
Response.Write(pdfDucment);
Response.Flush();
Response.End();