Display an image in an InfoPath 2007 browser-based form, without writing any managed code - InfoPath Dev
in

InfoPath Dev

Display an image in an InfoPath 2007 browser-based form, without writing any managed code

Last post 10-16-2008 12:42 PM by Hilary Stoupa. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 10-16-2008 10:53 AM

    Display an image in an InfoPath 2007 browser-based form, without writing any managed code

     It just took me awhile to figure this out, and hopefully writing it down will help somebody out in a similar situation to me.  

    GOAL:
    I wanted to display an image in an InfoPath 2007 browser-based form, without writing any managed code (I don't have Visual Studio).


    SOLUTION:
    To begin, I created a form with a rich text field, added a linked image, and submitted.

    I then examined the resulting XML file.  I saw how the link appeared in the xml file:

                <my:field1><html xmlns="http://www.w3.org/1999/xhtml"><div><img

    src="THE_URL_OF_THE_PICTURE_I_WAS_LINKING_TO" alt=""></img></div></html></my:field1>

    After many attempts with trying to set this as the default value for the rich text field field1, attempting to use escape characters and surrounding the expression with single quotes rather than double quotes, I eventually determined that it wouldn't work.  (Correct me if I'm wrong)

    So I then decided to do this:

    •Create Rich Text Field field1.  Make sure to have "wrap text" and "read-only" checked.  I made the size slightly larger than the image I was about to link to.

    •Save the form template as source files (see file menu)

    •Close the form in InfoPath

    •Open the template.xml file for this form

    •Replace
                 <my:field1></my:field1>
    with
                <my:field1><html xmlns="http://www.w3.org/1999/xhtml"><div><img src="THE_URL_OF_THE_PICTURE_I_WAS_LINKING_TO" alt=""></img></div></html></my:field1>

    •At this point, it looked like it was working when I reopened it in InfoPath in design mode, but when

    I previewed, the rich text box now contained the text above rather than the image.

    •So, I then used notepad to open the manifest.xsf file, I went in and deleted the following tag
    <xsf:calculatedField>...reference to my linked image...</xsf:calculatedField>
    that was created inside of <xsf:calculations></xsf:calculations>

    •After reopening the form in InfoPath and publishing, I opened the browser based form and it had worked!

    NOTES: 

    •The issue with the manifest file doesn't always come up  .

    •Using this method tends to make the form load slower the more images you use.  If anyone has a better solution to this problem I'd love to hear it.

    •I doubt editing the source files is something Microsoft likes us to do, but I couldn't find a better solution.

  • 10-16-2008 12:42 PM In reply to

    Re: Display an image in an InfoPath 2007 browser-based form, without writing any managed code

    Thank you for taking the time to post this! Hopefully if someone has another solution, they'll add it to the thread. You actually already helped me -- I hadn't realized that rich text boxes behaved differently in browser forms than in forms intended to be opened with InfoPath. It makes sense that they do -- it just wasn't something I'd run into before!

    Hilary Stoupa

Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.