Bind picture control to field in XML data source

Posted by: jim.wilson on 22 October 2022, 7:22 am EST

    • Post Options:
    • Link

    Posted 22 October 2022, 7:22 am EST

    Does anyone know how to include PNG images in an XML document serving as the data source such that a picture control can be bound to them? Is it even possible?

  • Posted 27 October 2022, 5:04 pm EST

    Hi Jim,

    One of the ways you can do this is to embed the image as a byte array in your XML Document. Then you will be able to load the image in Page/RDL Reports and Section Reports as well.

    To convert the image to ByteArray please refer to the following lines of code:

                using (MemoryStream m = new MemoryStream())
                    image.Save(m, image.RawFormat);
                    ByteArray = m.ToArray();

    Please note while creating an XML Document make sure the XML Document is encoded using UTF-8 encoding. Based on the above approach I have created a sample application and attached it along with for your reference.



  • Posted 1 November 2022, 1:58 pm EST - Updated 2 November 2022, 11:27 am EST


    Thank you for your clear response with sample code. What you provided was beyond my needs, but it did put me on the path to track down and validate a rather simple answer.

    string imageContentForXml = Convert.ToBase64String(File.ReadAllBytes("C:/users/jim/1.jpg")))

    I recommend adding a note in the documentation about images in XML data sources should be Base64 encoded.

    Thanks again.


  • Posted 2 November 2022, 7:31 pm EST

    Hi Jim,

    Thanks for the suggestion. As long as you can load your image into a System.Drawing.Image object you can load that image into the Picture control of Section Reports to display your image into the report through code.

    Although, we have listed the supported image formats for Picture Control in our documentation.

    Picture control supports Base64 string, Byte[], BMP, JPG, JPEG, JPE, GIF, PNG, EMF, and WMF formats in both GDI and CrossPlatform compatibility modes.

    You can learn more about Picture control on the following page of our documentation:



  • Posted 3 November 2022, 12:50 am EST

    Totally missed that. I was looking at the documentation from a data source perspective rather than from a Picture control perspective. What through me off a bit (my own fault) is that in the designer I loaded an image in the Picture control, saved the rpx file, opened the rpx file in VS Code, and noted encoding that was not base64. I drew a wrong conclusion. Anyway, it’s all good thanks to your assistance. Your team is great. Keep up the good work!

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels