protected void WriteColourSetting(XmlTextWriter xml, iText.Kernel.Colors.Color iTextColour, String name) { if (iTextColour.GetColorSpace().ToString() == "iText.Kernel.Pdf.Colorspace.PdfDeviceCs+Cmyk") { MessageBox.Show("Wrong Colour Space", "Not SUpported", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { float[] float_rgb = iTextColour.GetColorValue(); int r = Convert.ToInt32(Math.Round(255 * float_rgb[0])); int g = Convert.ToInt32(Math.Round(255 * float_rgb[1])); int b = Convert.ToInt32(Math.Round(255 * float_rgb[2])); String attribute = r.ToString() + "," + g.ToString() + "," + b.ToString(); xml.WriteAttributeString(name, attribute); } }
public Color ProcessColorInfo(iText.Kernel.Colors.Color color) { if (color.GetColorSpace() is PdfDeviceCs.Cmyk) { color = iText.Kernel.Colors.Color.ConvertCmykToRgb((DeviceCmyk)color); } if (color.GetNumberOfComponents() == 1) { return(new Color((int)color.GetColorValue()[0])); } if (color.GetNumberOfComponents() == 3) { return(new Color(color.GetColorValue()[0], color.GetColorValue()[1], color.GetColorValue()[2])); } return(null); // todo handle }
public PatternColor(PdfPattern.Tiling uncoloredPattern, Color color) : this(uncoloredPattern, color.GetColorSpace(), color.GetColorValue()) { }