Ejemplo n.º 1
0
        public override string render()
        {
            StringBuilder rtf = new StringBuilder();

            // ---------------------------------------------------
            // Prologue
            // ---------------------------------------------------
            rtf.AppendLine(@"{\rtf1\ansi\deff0");
            rtf.AppendLine();

            // ---------------------------------------------------
            // Insert font table
            // ---------------------------------------------------
            rtf.AppendLine(@"{\fonttbl");
            for (int i = 0; i < _fontTable.Count; i++)
            {
                rtf.AppendLine(@"{\f" + i + " " + RtfUtility.unicodeEncode(_fontTable[i].ToString()) + ";}");
            }
            rtf.AppendLine("}");
            rtf.AppendLine();

            // ---------------------------------------------------
            // Insert color table
            // ---------------------------------------------------
            rtf.AppendLine(@"{\colortbl");
            rtf.AppendLine(";");
            for (int i = 1; i < _colorTable.Count; i++)
            {
                RtfColor c = _colorTable[i];
                rtf.AppendLine(@"\red" + c.Red + @"\green" + c.Green + @"\blue" + c.Blue + ";");
            }
            rtf.AppendLine("}");
            rtf.AppendLine();

            // ---------------------------------------------------
            // Preliminary
            // ---------------------------------------------------
            rtf.AppendLine(@"\deflang" + (int)_lcid + @"\plain\fs"
                           + RtfUtility.pt2HalfPt(DefaultValue.FontSize) + @"\widowctrl\hyphauto\ftnbj");
            // page size
            rtf.AppendLine(@"\paperw" + RtfUtility.paperWidthInTwip(_paper, _orientation)
                           + @"\paperh" + RtfUtility.paperHeightInTwip(_paper, _orientation));
            // page margin
            rtf.AppendLine(@"\margt" + RtfUtility.pt2Twip(_margins[Direction.Top]));
            rtf.AppendLine(@"\margr" + RtfUtility.pt2Twip(_margins[Direction.Right]));
            rtf.AppendLine(@"\margb" + RtfUtility.pt2Twip(_margins[Direction.Bottom]));
            rtf.AppendLine(@"\margl" + RtfUtility.pt2Twip(_margins[Direction.Left]));
            // orientation
            if (_orientation == PaperOrientation.Landscape)
            {
                rtf.AppendLine(@"\landscape");
            }
            // header/footer
            if (_header != null)
            {
                rtf.Append(_header.render());
            }
            if (_footer != null)
            {
                rtf.Append(_footer.render());
            }
            rtf.AppendLine();

            // ---------------------------------------------------
            // Document body
            // ---------------------------------------------------
            rtf.Append(base.render());

            // ---------------------------------------------------
            // Ending
            // ---------------------------------------------------
            rtf.AppendLine("}");

            return(rtf.ToString());
        }
Ejemplo n.º 2
0
        public ColorDescriptor createColor(System.Drawing.Color color)
        {
            var rtfColor = new RtfColor(color.R, color.G, color.B);

            return(createColor(rtfColor));
        }