コード例 #1
0
ファイル: PDF.cs プロジェクト: jdaomilang/report-generator
            public static Demon.PDF.Color Color(Demon.Report.Style.Color color)
            {
                if (color == null)
                {
                    return(null);
                }

                return(new Demon.PDF.Color(color.Red, color.Green, color.Blue));
            }
コード例 #2
0
 public Run(string text, s.Font font, s.Color color)
 {
     _text  = text;
     _font  = font;
     _color = color;
 }
コード例 #3
0
        public void AddRun(string text, s.Font font, s.Color color)
        {
            Run run = new Run(text, font, color);

            _content.Add(run);
        }
コード例 #4
0
        public static XElement AddRunProperties(XElement run, s.Font font, s.Color color)
        {
            XNamespace ns = run.Name.Namespace;

            XElement rPr = new XElement(ns + "rPr");

            run.Add(rPr);

            XElement rFonts = new XElement(
                ns + "rFonts",
                new XAttribute(ns + "ascii", font.FamilyName),
                new XAttribute(ns + "cs", font.FamilyName));

            rPr.Add(rFonts);

            //	Font size is measured in half points in Word
            XElement size = new XElement(
                ns + "sz",
                new XAttribute(ns + "val", font.Size * 2));

            rPr.Add(size);

            if (font.Bold)
            {
                XElement bold = new XElement(
                    ns + "b",
                    new XAttribute(ns + "val", "true"));
                rPr.Add(bold);
            }
            if (font.Italic)
            {
                XElement italic = new XElement(
                    ns + "i",
                    new XAttribute(ns + "val", "true"));
                rPr.Add(italic);
            }
            if (font.Underline)
            {
                XElement underline = new XElement(
                    ns + "u",
                    new XAttribute(ns + "val", "single"));
                rPr.Add(underline);
            }
            if (font.Strikeout)
            {
                XElement strikeout = new XElement(
                    ns + "strike",
                    new XAttribute(ns + "val", "true"));
                rPr.Add(strikeout);
            }

            if (color != null)
            {
                int      red       = (int)(color.Red * 255f);
                int      green     = (int)(color.Green * 255f);
                int      blue      = (int)(color.Blue * 255f);
                string   value     = $"{red:X2}{green:X2}{blue:X2}";
                XElement colorElem = new XElement(
                    ns + "color",
                    new XAttribute(ns + "val", value));
                rPr.Add(colorElem);
            }

            return(rPr);
        }