Recently I had to build a report where some images were required, although I did not have those images they were available on other reports as embedded images.
From https://msdn.microsoft.com/en-us/library/dd239394.aspx I found which embedded images are stored on reports within its report definition (rdl file) base64 encoded.
So I took the next steps to build the images I needed to add on the new report:
- Report definition file stores images on the EmbeddedImages element. So, I copied that section and created an new XML file.
<?xml version="1.0" encoding="utf-8" ?> <EmbeddedImages> <EmbeddedImage Name="logo"> <MIMEType>image/png</MIMEType> <ImageData>image base64 encoded</ImageData> </EmbeddedImage> </EmbeddedImages>
- Then created a C# console application with the code bellow to create the image file from the XML file and got the images to add to the report.
XDocument xDoc = new XDocument(); xDoc = XDocument.Load("ReportImages.xml"); foreach (XElement xElem in xDoc.Elements("EmbeddedImages").Elements("EmbeddedImage")) { String name = xElem.Attribute("Name").Value; String type = xElem.Element("MIMEType").Value; String data = xElem.Element("ImageData").Value; String fileName = String.Format("{0}.{1}", name, type.Substring(type.IndexOf('/') + 1)); File.WriteAllBytes(fileName, Convert.FromBase64String(data)); }
*This post is locked for comments