How-To: insert images programmatically - InfoPath Dev
in

InfoPath Dev

How-To: insert images programmatically

Last post 03-30-2006 11:07 PM by Patrick Halstead. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 03-30-2006 12:28 AM

    How-To: insert images programmatically

    Since it takes some quirks to make this work, i thought i'd post a 5 liner to show how to add pictures on the fly with managed code.

    In my example it was file attachments that needed to be converted to pictures for print view, but it could as well be a dropdown with with images in a Picture Library, folder or database, where you want to show the selected picture when selection changes.

    IXMLDOMNode picture = yourNodeList.selectSingleNode("my:picture");//this is where you want to put your picture. Could be a repeating list with a dummy picture object
    byte[] bytes = yourBinaryPicture;//this is a byte array containing the picture in binary format

    if ( ((IXMLDOMElement)picture).getAttribute("xsi:nil") != null )
    ((IXMLDOMElement)picture).removeAttribute("xsi:nil");//remove attribute that specifies that the field has no value

    picture.nodeTypedValue = Convert.ToBase64String(yourBinaryPicture);//convert byte array to a Base64 encoded string and insert into nodeTypedValue property

    hope this saves some head scratching for someone :-)
  • 03-30-2006 11:07 PM In reply to

    Re: How-To: insert images programmatically

    Hi Anders,
    Most excellent post! You rock man! Keep it up!
    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.