PDF Background Color from Hex

Hello,

i'm trying to change the Background-Color from the PDF i generate.
I need to use HEX Values, not the Syncfusion.Drawing Colors.

I'm trying to use the ColorTranslator.Fromhtml:


Data from Syncfusion.Drawing.ColorTranslator.FromHtml("#000000"):

With FromHtml(Hex) the Background is still white.

----------------------------------

This is working:


Data from Syncfusion.Drawing.Color.DodgerBlue:

With DodgerBlue the PDF Background is Blue and works.


What can i do to use Hex values for the PDF Background?
(I'm using the Webkit Engine)


Thanks for help,

Nils


9 Replies

GK Gowthamraj Kumar Syncfusion Team July 26, 2021 12:53 PM UTC

Hi Nils, 
 
Thank you for contacting Syncfusion support.

 
We are able to reproduce the issue with “White background color while using color from hex value”, currently we are validating on this and we will update further details by July 28, 2021.  
 
Regards, 
Gowthamraj K 



GK Gowthamraj Kumar Syncfusion Team July 28, 2021 02:56 PM UTC

Hi Nils, 
 
Sorry for the inconvenience caused. 
 
Due to the complexities we are still validating the reported issue. We are still working on this issue with high priority and we will update further validation details by July 30th , 2021. 
 
Regards,  
Gowthamraj K 



NS Nils Steinle July 29, 2021 06:18 AM UTC

Hi Gowthamraj,


thanks for the Information.

please consider: i created the topic in topic ASP.NET MVC - EJ 2, but I'm using blazor (the update need to be done in blazor) :)


thanks for you help

Nils



SG Sivaram Gunabalan Syncfusion Team July 30, 2021 03:21 PM UTC

Hi Nils,  
  
Sorry for the inconvenience caused.  
  
We have checked the reported issue with “White background color while using color from hex value” . We do not have complete support to set background color using hex values. It is returns the RGB value of the hex values. Generally, the RGB can be different combination and each has some color name. Syncfusion.Drawing cannot provide names for these combinations to set background color. We can use color name directly to set the background color using Syncfusion.Drawing.Color property. 
 
Please let us know if you need any further assistance on this. 
 
Regards,   
Sivaram G 



NS Nils Steinle August 2, 2021 06:31 AM UTC

Hello,

so there is no way to take the color out of the colorpicker?

<SfColorPicker Mode="ColorPickerMode.Palette" ShowButtons="false" ModeSwitcher="false" ValueChange="@ColorPicked"></SfColorPicker>

And use it as PDF Background? :/

 

that would be very annoying. is there an alternative? or do you have another idea?


Regards,

Nils





NS Nils Steinle August 2, 2021 02:59 PM UTC

I've built my own color-picker with the drawing.colors now, so this topic is solved.

unfortunately the colors are not as nice and flexible as the ones from the hex-palette and the hex-picker is unusable. it would be nice if the translation from hex to syncfusion.color is integrated sometime in the future.


thanks for your assist

Nils



PV Prakash Viswanathan Syncfusion Team August 3, 2021 04:25 PM UTC

Hi Nils, 

Thank you for the update. As we said earlier, we do not have any plans to implement this support. However, if we will analyse further on converting color values from hex string and we will update the further details by Aug 5, 2021.   

Regards, 
Prakash V 



PV Prakash Viswanathan Syncfusion Team August 5, 2021 12:22 PM UTC

Hi Nils,  

We regret the inconvenience caused.  

We are still checking the analysing the possibilities to create a feature request and we will update further details by Aug 6, 2021.   

Regards,  
Prakash V 



GK Gowthamraj Kumar Syncfusion Team August 6, 2021 04:48 PM UTC

Hi Nils, 
 
Thank you for your patience.

 
We have checked the possibilities on our end. Unfortunately, we can’t implement it in our control. Because comparing the RGB values for known colors takes time and it will result in performance degradation. However, we have found a workaround using System.Drawing which can be implemented on your sample level. It will provide known color names while getting color using HTML Hex values.  

Code snippet: 
Syncfusion.Drawing.Color color = Syncfusion.Drawing.ColorTranslator.FromHtml("#1e90ff"); 
 
foreach (string name in Enum.GetNames(typeof(System.Drawing.KnownColor))) 
{ 
   if (color.ToArgb() == Syncfusion.Drawing.Color.FromName(name).ToArgb()) 
   { 
      Console.WriteLine(name); 
      settings.BackgroundColor = Syncfusion.Drawing.Color.FromName(name); 
      break; 
   } 
} 
 
Please let us know if you need any further assistance with this. 
 
Regards, 
Gowthamraj K 


Loader.
Up arrow icon