WriteSelectedRows doesnt show a table on PDF

2019-09-17 17:40发布

问题:

I need to split a big pdfptable with many colums, i use WriteSelectedRows, but there is no table showing up on my pdf.

When i delete the WriteSelectedRows methode, and print the full table on the pdf its all working fine.

Do i miss something?

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();