i want add image specific location in pdf file using itext in android. fillable form , have added textbox place holder image , want textbox , image this.
public class formfill { public static void fill(acrofields form, person person) throws ioexception, documentexception{ form.setfield("firstname", person.getfirstname()); form.setfield("lastname", person.getlastname()); form.setfield("imagetextbox", "???"); }
i have image uri so
uri imageuri = uri.parse(person.getimagepath());
any appreciated.
try this. have used function add image in document.
public void addlogo(document document) throws documentexception { try { // user settings generalsettings getusersettings = rectangle rectdoc = document.getpagesize(); float width = rectdoc.getwidth(); float height = rectdoc.getheight(); float imagestartx = width - document.rightmargin() - 315f; float imagestarty = height - document.topmargin() - 80f; system.gc(); inputstream ims = getassets().open("splashscreen.jpg"); bitmap bmp = bitmapfactory.decodestream(ims); bytearrayoutputstream stream = new bytearrayoutputstream(); bmp.compress(bitmap.compressformat.jpeg, 50, stream); byte[] bytearray = stream.tobytearray(); // pdfimage img = new pdfimage(arg0, arg1, arg2) // converting byte array image image img = image img = image.getinstance(bytearray); // img.scalepercent(50); img.setalignment(image.textwrap); img.scaleabsolute(200f, 50f); img.setabsoluteposition(imagestartx, imagestarty); // adding image document.add(img); } catch (exception e) { e.printstacktrace(); } }