> Date: Wed, 29 Sep 2010 14:50:41 -0700 > From: scott.k.mitch...@gmail.com > To: itext-questions@lists.sourceforge.net > Subject: [iText-questions] Adding image to text box field in a PDF > template file
... > I did some Googling and came up with > this article, which seems pretty spot on: > http://coolwebdeveloper.com/2008/10/how-to-use-itextsharp-net-pdf-library-to-insert-text-and-image-in-an-existing-pdf-form-template/ > > In it, the author presents code that (presumably) creates an Image > object, determines the position of the text box field, resizes the > image, and then adds the image to that field. I say "presumably" > because the code seems to have some errors (perhaps he is using an > earlier version of iTextSharp). For instance, there is this line of > code to determine the field position: > > float[] imageArea = testForm.GetFieldPositions(”testImage1″); > > (Here, testForm is an AcroFields object.) However, when I examine the > GetFieldPositions method, it tells me it returns an > IList, not an array of floats. yes, the article you refer to is using an older version. since 5.0.2.0 iTextSharp GetFieldPositions() returns IList<FieldPosition>. here are the appropriate links: http://api.itextpdf.com/com/itextpdf/text/pdf/AcroFields.html#getFieldPositions(java.lang.String) http://api.itextpdf.com/com/itextpdf/text/pdf/AcroFields.FieldPosition.html so something like this: // fields is an AcroFields object var f = fields.GetFieldPositions(k)[0]; then access the coordinates (llx, lly, urx, ury): f.position.Left, f.position.Bottom, f.position.Right, f.position.Top ------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.itextpdf.com/book/ Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/