itextsharp image could not display in pdfpcell

not sure what causes the problem

when i use plain text and colspan 3, it seems working fine

but when i use colspan 4 and try to place an image, it seems got problem

   Document document = new Document(PageSize.A4, 20f, 20f, 20f, 20f);

            PdfWriter.GetInstance(docu<wbr ></wbr>ment, new FileStream(filename, FileMode.Create));
         //   PdfAWriter.GetInstance(doc<wbr ></wbr>ument, new FileStream(Request.Physica<wbr ></wbr>lApplicati<wbr ></wbr>onPath + "Scripts\\1.pdf", FileMode.Create));
        //    document.Open();
            PdfPTable table = new PdfPTable(4);
            table.TotalWidth = 400f;
            //fix the absolute width of the table
            table.LockedWidth = true;

            //relative col widths in proportions - 1/3 and 2/3
            float[] widths = new float[] { 2f, 4f, 6f };
            table.HorizontalAlignment = 0;
            //leave a gap before and after the table
            table.SpacingBefore = 20f;
            table.SpacingAfter = 30f;

            PdfPCell cell = new PdfPCell(new Phrase("Header spanning 3 columns"));
            cell.Colspan = 4;
            cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right


            iTextSharp.text.Image image = iTextSharp.text.Image.GetI<wbr ></wbr>nstance(@"<wbr ></wbr>~/images/he<wbr ></wbr>ader.jpg")<wbr ></wbr>;
            image.ScaleAbsolute(800f, 300f);
            PdfPCell cell1 = new PdfPCell(image);

            cell1.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            table.AddCell("Col 1 Row 1");
            table.AddCell("Col 2 Row 1");
            table.AddCell("Col 1 Row 1");
            table.AddCell("Col 2 Row 1");
            table.AddCell("Col 3 Row 1");
            table.AddCell("Col 1 Row 2");
            table.AddCell("Col 2 Row 2");
            table.AddCell("Col 3 Row 2");
        catch (Exception ex)
          //  Response.Redirect("Scripts<wbr ></wbr>/1.pdf");

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

doramail05Author Commented:
Notice that if i put the image before table, it will appear the image with the following code,

just what if it is inside the cell? which i couldnt display 'em inside the cell

  PdfWriter.GetInstance(document, new FileStream(filename, FileMode.Create));

          //  document.Add(new Paragraph("JPG"));
            iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(imagepath + "/header1.jpg");
            jpg.ScaleAbsolute(550f, 120f);

        // //   PdfAWriter.GetInstance(document, new FileStream(Request.PhysicalApplicationPath + "Scripts\\1.pdf", FileMode.Create));
        ////    document.Open();
            PdfPTable table = new PdfPTable(3);
            table.TotalWidth = 400f;
doramail05Author Commented:
just discover that it just have to put



now was wondering what if would like to add a background image to the table, but couldnt find quite relevant resource on net,
doramail05Author Commented:
solved with this

iTextSharp.text.Image imgmrstext = iTextSharp.text.Image.GetInstance(imagepath + "/mrs_text.jpg");
            imgmrstext.ScaleAbsolute(35f, 35f);

   PdfPCell cell118 = new PdfPCell();
            cell118.BorderColor = iTextSharp.text.BaseColor.WHITE;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
doramail05Author Commented:
figured out
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.