tags:

views:

16

answers:

0

I'm looking to get the absolute position of an image. I have added the Image like this

PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("pdffile.pdf", FileMode.Create)); document.Open(); iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance("vehicle.png"); img.ScaleAbsolute(80, 40); cell = new PdfPCell(new Phrase(new Chunk(img, 0, 0))); hTable.AddCell(cell); document.Add(hTable);

I then need to retrieve the position of the image to draw a circle on the image. Based on the value retrieved from the DB i should draw the circle in any one of the 17 parts within the image.

I do it like this.

PdfContentByte cb = writer.DirectContent; cb.SetLineWidth(1f); cb.Circle(img.AbsoluteX, img.AbsoluteY, 15f); cb.stroke();

but img.AbsolutX gives NaN.

Please let me know how to get the position of the image in the PDF. The number of pages in the PDf is dynamic.