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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Image background color always black

Thread ID:

Created:

Updated:

Platform:

Replies:

142284 Jan 25,2019 12:38 AM UTC Jan 31,2019 12:25 PM UTC ASP.NET Core - EJ 2 1
loading
Tags: PDF
Ernest Mallett
Asked On January 25, 2019 12:38 AM UTC

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");
        }
    }

Dilli Babu Nandha Gopal [Syncfusion]
Replied On 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.  

Regards, 
Dilli babu. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon