Passing a Base64 String to Image Object

T

TKO

Please help me with this scenario involving 2 InfoPath forms:

Form A: contains 3 items, 1) picture object (field1), 2) a textbox that
stores the base64 string of the picture (field2), and 3) another
textbox to store a name for the picture (field3).

User clicks on the picture object and embeds an image. the value for
field2 is automatically updates with the value from field1. User
enters a name in field3, and saves the form to a SharePoint library.
field2 and field3 are published to the SharePoint library.

I have added 20 forms into the SharePoint form library, so there are
now 20 different pictures



Form B: an independent form sitting on my desktop, not part of any
SharePoint libraries. It contains a blank picture object (test1) and a
repeating table bound to a connection to the above forms library. Each
rown in the table contains a button and 2 fields for each record -
field2 (the picture's name), and field3 (the base64 string)



What I'm trying to do...

Inside FormB, when I click on a button on a specific row, I want to
take the base64 string from that row, and feed that to the blank
picture object on FormB to see the picture. I can't get it to work.
Please help!!
 
V

virgul

Hi

I found that on Infopathdev.com that can help you to understand:

Decode InfoPath Images for Display on Your Web Site
By Patrick Halstead, 2003-12-09

You can take the "msoinline" tagged images that InfoPath generates in
it's XML content for images and decode it. The images are encoded in
Base64.

Basically, what you want to do is to convert:
<img style="WIDTH: 239px; HEIGHT: 47px" tabIndex="-1"
src="msoinline/34f6f7af90534a44" xmlns:xd=".....">

into something like:
<img href="..."> or <img src="...">

IE doesn't support inline images, so you will need to create a
component that does "on demand" decoding of the image on the server.
You can use an .ashx page to do this.

First step is to replace the src URL with something like
"base64decoder.ashx?doc=...&img=..."

In the base64decoder.ashx code, locate the base64 content in the
document and then call Text.Encoding.base64decode returning the stream
to the caller specifying content-type="image/gif"

IE will send separate requests for each image.

Sound cool? The full-fledged nugget will be posted at a later time.
++
 
T

TKO

Thanks for your reply virgul, but what I'm trying to do is converting
the base64 string back to a picture INSIDE InfoPath, not on a webpage.
Any idea how this can be done? Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top