Convert SVG graphics to PNG picture
Environment
Product Version | 13.0.19.222 |
Product | Progress® Telerik® Reporting |
Description
Currently, the PictureBox can hold only the formats supported by GDI+ (BMP, GIF, JPEG, EXIF, PNG, and TIFF). This KB article demonstrates how to convert SVG graphics to PNG picture and to set it as a value of the picturebox. Note that a NuGet package called Svg should be added to the project. The approach is approperiate for reports which are designed in the Standalone Designer, as well as in the Visual Studio Report Designer.
Solution
-
A UserFunction should be implemented through the code snippet below
public static Bitmap ConvertToBitmap(string url) { var svgDocument = Svg.SvgDocument.Open(url); svgDocument.ShapeRendering = SvgShapeRendering.Auto; Bitmap bmp = svgDocument.Draw(120, 120); // Draw Bitmap in any Size you need - for example 120px x 120px return bmp; }
Register the user function as explained in Extending Report Designer article. A reference to the Svg.dll should be also attached.
-
Then the value of the picture box should be set to the following expression:
= UserFunctionClassName.ConvertToBitmap(Parameters.url.Value)
Note that the report parameter holds the URL for the picture.