Expand my Community achievements bar.

Load Image in ImageField on Button Click

Avatar

Level 4

Hi,

I have a form having a ImageField and a TextField. I want to give the image path in TextField and on button click it should load that image into image field.

load.jpg

Is it possible? I am unable to do it. Help.

Thanks.

-

Abhinav

7 Replies

Avatar

Level 9

Hi Abhinav,

You can directly do this by Image Field from the Object Pallete.Why do you need a TextField for that ?

Thanks.

Bibhu.

Avatar

Level 4

Hi Bibhu, Thanks for your reply.

Actually in future I have to deploy this form on LiveCycle ES2 server. I will be having the list of names/images pairs and I will use this form as a template. For each item in the list I will be creating a form having that name & image. It will be later saved on disk. So some process will be dynamically providing the names, image_paths (may from database). I hope you understand the problem. If any other way is there to do this functionality?

Thanks.

-

Abhinav

Avatar

Level 10

Hi Abhinav,

Not sure I understand your problem ... are the images meant to be something the user selects from thier file system?.  If not you can load an image by assigning the Image Field (not an Image) by assigning its rawValue a base64 encoded version of the image.

So something like;

ImageField1.rawValue = "R0lGODlhEAAQAPe8AP7//8sfH9Le6NPf6fz///3////t7ezh4dESEtcAALgcHOhQUOpQUMcyMu1dXdC7xNYREdR+ftMAAMU0NNHCy+NHR7sREtKlquI1NdNZWdHY4MYQEPfc3OFUVM92dvP09MAaGvidnfmentPa5PLs7NHb5dQAAOdKSv739+DBweQ7O9+RkdPe6ehmZuO9veVPT8cfH9LX39MfHv3+/to2NvaVlf319fz+/sjCyc8UFOt1ddDGzf/19fvt7dcYGOOEhMl5fe7t7erJyci7wbAtLuI2Nv7m5scsLNHDys2psMwgINGpr/KsrKxOUN2oqOizs9PR2e3g4NaJjNHX4tSAgvbS0sUPD8MGB/Tx8d4mJuzi4tEsLPW+vtV/gfn8/OOzs9qfn9gbG9YVFdcUFM9WVsgaGtYTE9Smq9Lb5udGRv3d3b4WFtJcXclhZO/Bwc8AAO/n58opKfHq6uE+PvuenuK3t/Cios6wt8KkqdiKitE8POI3N83FzN0oKOOcndygoP/6+s+Vm/3g4O9paeM6Os2dpNHS3LU8PcZfYupVVdHd59p0dPPw8NcZGcmChtUAALkdHeTCwuTLy61RU7+jqNLV3u9nZ/f5+dsfH9K5v9QREckaGsGoruFsbPSCgtAMDdBvb/SdnbmWmr1wc/Jtbf7OztgaGtC0u8JMTswNDdR8fMQXF84AAOOKis/IzuVgYM/R2fP29s5kZtDZ4taSktUjI/Z0dNqenuvm5tJgYNwvL////9Lf6gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAALwALAAAAAAQABAAAAj6AHkJFEhhyZkLpwwNXMjrgRQ3PVDY4OAnEBqGhX4Y4GFEjSADgLh0GTHwTqdSQr6EEEHHTooqoaiw4DWFTY0ncBitsKXDxSVJTF5l4pWkgycnBXZhyVMHwC5crUjJGgDkhaUWfwjs8uL0wKJBDvRUajPnRKIKtG7s2nUgA4MFaba4QqRrjwoaYGaslZMLA6EiSvg4kpGl1i2nH7SSIIOpDwhYSDZA8LA2yoQISYPEGXNIwABUnwJE0nIkwRtVsUAhuEJJIBQLmgLAkGDiEasGCFJNEjBwB6QcpnyYEROmkZUmsxjGGKVg1aYya4iIUsRwoIYheDjhKMEwIAA7";

There's plenty of websites that will encode an image for you.

Regards

Bruce

Avatar

Level 10

Hi,

Researching this, I can see that Bruce has a much better handle on this. John Brinkman's blog and Bruce's comments show how you can encode an attachment and set an imageField's rawValue with it.

http://blogs.adobe.com/formfeed/2009/08/base64_encode_a_pdf_attachment.html.

However in this case the process of adding an attachment is the same as clicking on the imageField and the user browsing and selecting an image. The user has to browse to the file; you cannot pre-specify the file to be attached.

In exploring this I amended the working on images file. On page 3, I have included a textfield where the user can specify an image in the same folder. This only works for images that have previously been loaded into the form (eg the thumbnails on pages 1 and 2).

http://www.assuredynamics.com/index.php/category/portfolio/working-with-images/

Acrobat1.png

What you MIGHT be able to do is set up a hidden imageField that sets its .rawValue to a set of images (in a loop). It would need to use the exact path as the user would type in. Users might then be able to reference these images.

Overall, I think it will be flakey, due to the potential for the user to mistype a path and the security restrictions.

Good luck,

Niall

Avatar

Level 4

Hi Bruce,

In my process Image Path (& other data) will be coming from database. This will then be inserted in form's XML Data. As you tell, we can't give the image path directly, we have to encode image in base64 value on the fly. I don't want to use any webservice or remote site to do this work. I want to do this inside the LC Server itself.

To encode image in base64 value I have done the following steps (inside process):

  1. Read JPG image in document variable;
  2. Convert this document to base64 using getDocContentBase64() function using SetValue Operation, Store result string in variable.
  3. Assign this value to imageField.rawValue.

But it still doesn't work. Pls help me out how can I get the proper base64 value for an image at runtime?

Thanks.

-

Abhinav

Avatar

Level 10

Hi Abhinav,

Sorry I can't help you here ... I've never used any of the LiveCycle server products.

Bruce