Expand my Community achievements bar.

Changing an image ina form dynamically?

Avatar

Level 6
Hi,



How to dynamically change the image of an image field? (staticimage or image field)?



I have tried this: xfa.form.form1.Subform1.StaticImage1.value.image.href = "C:\test.gif";



but it doesn´t work...



Thank you
4 Replies

Avatar

Level 8

I am facing the same problem. I even tried it under LiveCycle Desinger ES 8.1, still same problem.

I cannot change the image (href) during run-time using script. It only works if the href is passed from the XML File to the PDF Form during form redering.

Please help ! 

Avatar

Level 2

Im not sure how this could be done, but i can give you a way to bypass this.

You could always use multiple Subforms on top of eachother, each with an image inside wich you want to show.

You could then just hide and show the image you want using the presence of the subforms.

maybe not entirely what you want but it could help make it work in the meantime.

Avatar

Level 8

Thanks a lot for the reply, Rien and Yan.

However, I discovered that there has been change in behavior between Acrobat 7 and later versions with regards to the handling of HREF property for the Image Field. When I set the value of "href" property of the Image Field at the rime of redering the XDP, it is not working in Acrobat 9. I think the reason for this is security issues. They do not want the client to have a reference to a virtual location on the server. This is what is called probably the web bug or what ever !!!

But, I found a solution, following is a sample in ASP.NET to attache an image from the server which is decided during the render time from the server:

  StaffOhotoHREF = "<relative path to image file>"

  oImage = System.Drawing.Image.FromFile(Server.MapPath(StaffPhotoHREF))

  ms = New System.IO.MemoryStream

  oImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)

  strXML = strXML &"<ORGStaffPhoto xmlns:xfa=""http://www.xfa.org/schema/xfa-data/1.0/"" xfa:contentType=""image/jpg"" href="""" >"  _

           Convert.ToBase64String(ms.ToArray) + "</ORGStaffPhoto>"

  oImage.Dispose()

It works like a charm ...

Tarek.