We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Image background color always black

I am currently using the HtmlToPdfConverter to convert HTML to an image.  Every time the image comes out the background is always black.

The code that I am using is below:

    public class HtmlConverterService : IHtmlConverter
        public byte[] ConvertToByteArray(string html)
            HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
            WebKitConverterSettings settings = new WebKitConverterSettings();
            settings.WebKitPath = GetQtBinaries();
            settings.BackgroundColor = Color.White;
            settings.HtmlEncoding = Encoding.UTF8;
            settings.WebKitViewPort = new Size();
            htmlConverter.ConverterSettings = settings;
            Image document = htmlConverter.ConvertToImage(html, "");

            return document.ImageData;

        public string ConvertToBase64(string html)
            return "data:image/png;base64," + Convert.ToBase64String(ConvertToByteArray(html));

        private string GetQtBinaries()
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                return Path.Combine("QtBinaries", "QtBinariesWindows");
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
                return Path.Combine("QtBinaries", "QtBinariesLinux");
            return Path.Combine("QtBinaries", "QtBinariesMac");

1 Reply

DB Dilli Babu Nandha Gopal Syncfusion Team January 31, 2019 12:25 PM UTC

Hi Ernest, 

We have confirmed that the reported issue with “Background color is black when converting HTML to Image” is a defect. The fix for this issue will be included in our upcoming main release 2019 Volume 1 which is estimated to be available by March 2019 tentatively.  

Dilli babu. 

Live Chat Icon For mobile
Up arrow icon