Пример #1
0
        private void CreateCell(Table table, string str, float widthCell, iText.Kernel.Colors.Color bgColor)
        {
            Cell cell1 = new Cell();

            cell1.Add(new Paragraph(str));
            cell1.SetWidth(widthCell);
            cell1.SetFontSize(12);
            cell1.SetBackgroundColor(bgColor);
            table.AddCell(cell1);
        }
Пример #2
0
        private void AddResult(Document doc, string result, iText.Kernel.Colors.Color color)
        {
            Paragraph pQuestion = new Paragraph()
                                  .SetFontSize(30)
                                  .SetBold()
                                  .SetTextAlignment(TextAlignment.RIGHT)
                                  .SetMarginTop(5)
                                  .SetMarginBottom(5)
                                  .SetFontColor(color)
            ;

            pQuestion.Add(result);
            doc.Add(pQuestion);
        }
Пример #3
0
 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
        }