Exemplo n.º 1
0
        private void drawText(GraphicsTemplate xObj)
        {
            float         left = Border.Width * 2;
            StringBuilder text = new StringBuilder();

            for (int i = 0; i < Items.Count; ++i)
            {
                text.Append(Items[i]);
                if (i != Items.Count - 1)
                {
                    text.Append('\n');
                }
            }

            StringFormat format = new StringFormat();

            format.VerticalAlign = VerticalAlign.Top;
            if (TextAlign == TextAlign.Center)
            {
                format.HorizontalAlign = HorizontalAlign.Center;
            }
            else if (TextAlign == TextAlign.Left)
            {
                format.HorizontalAlign = HorizontalAlign.Left;
            }
            else if (TextAlign == TextAlign.Right)
            {
                format.HorizontalAlign = HorizontalAlign.Right;
            }
            xObj.BeginStringEdit();
            xObj.Transform(1, 0, 0, 1, 0, Height);
            xObj.DrawString(text.ToString(), Font, new SolidBrush(FontColor), new RectangleF(left, left + 2.5f, Width - 2 * left, Height - 2 * left), format);
            xObj.EndStringEdit();
        }
Exemplo n.º 2
0
        private void drawText(GraphicsTemplate xObj)
        {
            StringBuilder sb = new StringBuilder();

            if (_name != null && _name != "")
            {
                sb.Append("Digitally signed by: " + _name + "\n");
            }
            sb.Append("Date: " + DateTime.Now.ToString() + "\n");
            if (_reason != null && _reason != "")
            {
                sb.Append("Reason: " + _reason + "\n");
            }
            if (_location != null && _location != "")
            {
                sb.Append("Location: " + _location);
            }
            string text = sb.ToString();

            if (!string.IsNullOrEmpty(text))
            {
                xObj.BeginStringEdit();
                xObj.Transform(1, 0, 0, 1, 0, Height);

                drawMultilineText(text, xObj);

                xObj.EndStringEdit();
            }
        }
Exemplo n.º 3
0
        private void drawMultilineText(string text, GraphicsTemplate xObj)
        {
            float left = Border.Width * 2;

            if (Border.Style == BorderStyle.Beveled || Border.Style == BorderStyle.Inset)
            {
                left *= 2;
            }

            StringFormat format = new StringFormat();

            format.VerticalAlign = VerticalAlign.Top;
            if (TextAlign == TextAlign.Center)
            {
                format.HorizontalAlign = HorizontalAlign.Center;
            }
            else if (TextAlign == TextAlign.Left)
            {
                format.HorizontalAlign = HorizontalAlign.Left;
            }
            else if (TextAlign == TextAlign.Right)
            {
                format.HorizontalAlign = HorizontalAlign.Right;
            }

            xObj.DrawString(text, Font, new SolidBrush(FontColor), new RectangleF(left, left + 2.5f, getRotateWidth() - 2 * left, getRotateHeight() - 2 * left), format);
        }
Exemplo n.º 4
0
        private void drawInsertSpacesText(string text, GraphicsTemplate xObj)
        {
            if (BorderStyle == BorderStyle.Dashed || BorderStyle == BorderStyle.Solid)
            {
                drawSpacesCells(xObj);
            }

            float left = 0;

            float top    = 0;
            float height = getRotateHeight();
            float width  = getRotateWidth() / MaxLength;

            if (TextAlign == TextAlign.Right)
            {
                left = (MaxLength - text.Length) * width;
            }
            else if (TextAlign == TextAlign.Center)
            {
                left = (MaxLength - text.Length) / 2 * width;
            }

            StringFormat sf = new StringFormat();

            sf.HorizontalAlign = HorizontalAlign.Center;
            sf.VerticalAlign   = VerticalAlign.Center;
            Brush br = new SolidBrush(FontColor);

            for (int i = 0; i < text.Length; ++i)
            {
                xObj.DrawString(new string(text[i], 1), Font, br, new RectangleF(left, top, width, height), sf);
                left += width;
            }
        }
Exemplo n.º 5
0
        static void Main()
        {
            // Create new document
            Document pdfDocument = new Document();

            pdfDocument.RegistrationName = "demo";
            pdfDocument.RegistrationKey  = "demo";

            // Prepare simple template (for example, a logo) and draw it on every page

            // Create template of specified size
            GraphicsTemplate template = new GraphicsTemplate(250, 50);

            // Draw the logo
            template.DrawRectangle(new SolidBrush(new ColorRGB(192, 192, 255)), 0, 0, 250, 50);
            template.DrawString("My Company Logo", new Font(StandardFonts.TimesBoldItalic, 24), new SolidBrush(), 30, 10);

            // Add few pages and draw the prepared template on each one
            for (int i = 0; i < 3; i++)
            {
                Page page = new Page(PaperFormat.A4);
                page.Canvas.DrawTemplate(template, 10, 10);
                pdfDocument.Pages.Add(page);
            }

            // Save document to file
            pdfDocument.Save("result.pdf");

            // Cleanup
            pdfDocument.Dispose();

            // Open document in default PDF viewer app
            Process.Start("result.pdf");
        }
Exemplo n.º 6
0
        private void drawText(GraphicsTemplate xObj)
        {
            if (!string.IsNullOrEmpty(Text))
            {
                xObj.BeginStringEdit();
                xObj.Transform(1, 0, 0, 1, 0, getRotateHeight());

                string text = getDrawingText();

                if (Multiline)
                {
                    drawMultilineText(text, xObj);
                }
                else
                {
                    if (MaxLength != -1 && !Password && !Multiline && InsertSpaces)
                    {
                        drawInsertSpacesText(text, xObj);
                    }
                    else
                    {
                        drawOnelineText(text, xObj);
                    }
                }
                xObj.EndStringEdit();
            }
        }
Exemplo n.º 7
0
        private static PDFDictionary copyAppearance(PDFDictionary dict)
        {
            PDFDictionary result = new PDFDictionary();

            string[] keys = { "N", "R", "D" };
            for (int i = 0; i < keys.Length; ++i)
            {
                IPDFObject obj = dict[keys[i]];
                if (obj is PDFDictionaryStream)
                {
                    result.AddItem(keys[i], GraphicsTemplate.Copy(obj as PDFDictionaryStream));
                }
                else if (obj is PDFDictionary)
                {
                    PDFDictionary newDict = new PDFDictionary();
                    string[]      keys2   = (obj as PDFDictionary).GetKeys();
                    for (int j = 0; j < keys2.Length; ++j)
                    {
                        PDFDictionaryStream ds = (obj as PDFDictionary)[keys2[j]] as PDFDictionaryStream;
                        if (ds != null)
                        {
                            newDict.AddItem(keys2[j], GraphicsTemplate.Copy(ds));
                        }
                    }

                    result.AddItem(keys[i], newDict);
                }
            }

            return(result);
        }
Exemplo n.º 8
0
        internal static PDFDictionary Copy(PDFDictionary dict)
        {
            PDFDictionary result = new PDFDictionary();

            string[] keys = { "R", "BC", "BG", "CA", "RC", "AC", "TP", "IF" };
            for (int i = 0; i < keys.Length; ++i)
            {
                IPDFObject obj = dict[keys[i]];
                if (obj != null)
                {
                    result.AddItem(keys[i], obj.Clone());
                }
            }

            string[] xObjects = { "I", "RI", "IX" };
            for (int i = 0; i < xObjects.Length; ++i)
            {
                PDFDictionaryStream stream = dict[xObjects[i]] as PDFDictionaryStream;
                if (stream != null)
                {
                    result.AddItem(xObjects[i], GraphicsTemplate.Copy(stream));
                }
            }

            return(result);
        }
Exemplo n.º 9
0
        private void drawText(GraphicsTemplate xObj)
        {
            StringFormat format = new StringFormat();

            format.VerticalAlign   = VerticalAlign.Center;
            format.HorizontalAlign = HorizontalAlign.Center;
            xObj.DrawString(Caption, _font, new SolidBrush(_fontColor), new RectangleF(0, 0, Width, Height), format);
        }
Exemplo n.º 10
0
 internal void DrawBackground(GraphicsTemplate xObj)
 {
     if (BackgroundColor != null)
     {
         Brush br = new SolidBrush(BackgroundColor);
         xObj.DrawRectangle(br, new RectangleF(0, 0, Width, Height));
     }
 }
Exemplo n.º 11
0
 private void drawBorder(GraphicsTemplate xObj)
 {
     if (BackgroundColor != null)
     {
         Brush br = new SolidBrush(BackgroundColor);
         xObj.DrawRectangle(br, new RectangleF(0, 0, getRotateWidth(), getRotateHeight()));
     }
 }
Exemplo n.º 12
0
        private void drawTick(GraphicsTemplate xObj)
        {
            Brush br = BorderColor == null
                                ? new SolidBrush()
                                : new SolidBrush(BorderColor);

            xObj.DrawCircle(br, Width / 2, Height / 2, Math.Min(Width, Height) / 4 - BorderWidth);
        }
Exemplo n.º 13
0
        internal override void CreateApperance()
        {
            PDFDictionary    ap = new PDFDictionary();
            GraphicsTemplate n  = new GraphicsTemplate(getRotateWidth(), getRotateHeight(), getRotateMatrix());

            drawBackground(n);
            drawBorder(n);
            drawText(n);
            ap.AddItem("N", n.GetDictionaryStream());
            Dictionary.AddItem("AP", ap);
        }
Exemplo n.º 14
0
        internal override void CreateApperance()
        {
            PDFDictionary    ap = new PDFDictionary();
            GraphicsTemplate n  = new GraphicsTemplate(Width, Height, new float[] { 1, 0, 0, 1, 0, 0 });

            DrawBackground(n);
            DrawBorder(n);
            drawText(n);

            ap.AddItem("N", n.GetDictionaryStream());
            Dictionary.AddItem("AP", ap);
        }
Exemplo n.º 15
0
        private void drawContents(GraphicsTemplate xObj)
        {
            if (BackgroundColor != null)
            {
                Brush br = new SolidBrush(BackgroundColor);
                xObj.DrawCircle(br, Width / 2, Height / 2, Math.Min(Width, Height) / 2 - BorderWidth);
            }

            if (BorderColor != null)
            {
                Pen pen = new SolidPen(BorderColor);
                pen.Width = BorderWidth;
                xObj.DrawCircle(pen, Width / 2, Height / 2, Math.Min(Width, Height) / 2 - BorderWidth);
            }
        }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            var PDFSDK_RegName = "demo";
            var PDFSDK_RegKey  = "demo";

            Document templateDoc = new Document {
                RegistrationName = PDFSDK_RegName, RegistrationKey = PDFSDK_RegKey
            };
            Document mainDoc = new Document {
                RegistrationName = PDFSDK_RegName, RegistrationKey = PDFSDK_RegKey
            };
            Document resultDoc = new Document {
                RegistrationName = PDFSDK_RegName, RegistrationKey = PDFSDK_RegKey
            };

            templateDoc.Load(@"./background.pdf");
            mainDoc.Load(@"./sample.pdf");

            // Create GraphicsTemplate object from the first page of the template document
            GraphicsTemplate template = templateDoc.Pages[0].SaveAsTemplate();

            for (int i = 0; i < mainDoc.Pages.Count; i++)
            {
                // Create empty page
                Page resultPage = new Page(mainDoc.Pages[i].Width, mainDoc.Pages[i].Height);

                // Draw the template page as a background before the main content
                resultPage.Canvas.DrawTemplate(template, 0, 0);

                // Draw main content
                GraphicsTemplate mainContentAsTemplate = mainDoc.Pages[i].SaveAsTemplate();
                resultPage.Canvas.DrawTemplate(mainContentAsTemplate, 0, 0);

                // Add the created page to the result document
                resultDoc.Pages.Add(resultPage);
            }

            // Save result document
            resultDoc.Save(@"./result.pdf");

            resultDoc.Dispose();
            templateDoc.Dispose();
            mainDoc.Dispose();

            Console.WriteLine("Result file 'result.pdf' generated!");
            Process.Start(@"result.pdf");
            Console.ReadLine();
        }
Exemplo n.º 17
0
        internal override void CreateApperance()
        {
            PDFDictionary    ap  = new PDFDictionary();
            PDFDictionary    n   = new PDFDictionary();
            GraphicsTemplate off = new GraphicsTemplate(Width, Height, new float[] { 1, 0, 0, 1, 0, 0 });
            GraphicsTemplate yes = new GraphicsTemplate(Width, Height, new float[] { 1, 0, 0, 1, 0, 0 });

            drawContents(off);
            drawContents(yes);
            drawTick(yes);

            n.AddItem("Off", off.GetDictionaryStream());
            n.AddItem(_exportValue, yes.GetDictionaryStream());
            ap.AddItem("N", n);
            Dictionary.AddItem("AP", ap);
        }
Exemplo n.º 18
0
        internal void DrawBorder(GraphicsTemplate xObj)
        {
            if (BorderColor != null)
            {
                Pen pen = new SolidPen(BorderColor);
                pen.Width = Border.Width;
                if (Border.Style == BorderStyle.Underline)
                {
                    xObj.DrawLine(pen, 0, Height - pen.Width / 2, Width, Height - pen.Width / 2);
                }
                else
                {
                    RectangleF rect = new RectangleF(pen.Width / 2, pen.Width / 2, Width - pen.Width, Height - pen.Width);
                    if (Border.Style == BorderStyle.Dashed)
                    {
                        pen.DashPattern = Border.DashPattern;
                    }
                    xObj.DrawRectangle(pen, rect);

                    if (Border.Style == BorderStyle.Inset)
                    {
                        Pen insPen = new SolidPen(new ColorRGB(128, 128, 128));
                        insPen.Width = Border.Width;
                        xObj.DrawLine(insPen, insPen.Width, 1.5f * insPen.Width, Width - insPen.Width, 1.5f * insPen.Width);
                        xObj.DrawLine(insPen, 1.5f * insPen.Width, 1.5f * insPen.Width, 1.5f * insPen.Width, Height - insPen.Width);
                    }

                    if (Border.Style == BorderStyle.Inset || Border.Style == BorderStyle.Beveled)
                    {
                        float width = Border.Width;
                        Path  path  = new Path();
                        path.MoveTo(width, Height - width);
                        path.AddLineTo(2 * width, Height - 2 * width);
                        path.AddLineTo(Width - 2 * width, Height - 2 * width);
                        path.AddLineTo(Width - 2 * width, 2 * width);
                        path.AddLineTo(Width - width, width);
                        path.AddLineTo(Width - width, Height - width);
                        path.ClosePath();

                        Brush br = new SolidBrush(new ColorRGB(192, 192, 192));
                        xObj.DrawPath(br, path);
                    }
                }
            }
        }
Exemplo n.º 19
0
        internal override void CreateApperance()
        {
            PDFDictionary    ap  = new PDFDictionary();
            PDFDictionary    n   = new PDFDictionary();
            GraphicsTemplate off = new GraphicsTemplate(Width, Height, new float[] { 1, 0, 0, 1, 0, 0 });
            GraphicsTemplate yes = new GraphicsTemplate(Width, Height, new float[] { 1, 0, 0, 1, 0, 0 });

            DrawBackground(off);
            DrawBorder(off);
            DrawBackground(yes);
            DrawBorder(yes);
            drawTick(yes);

            n.AddItem("Off", off.GetDictionaryStream());
            n.AddItem("Yes", yes.GetDictionaryStream());
            ap.AddItem("N", n);
            Dictionary.AddItem("AP", ap);
        }
Exemplo n.º 20
0
        static void Main(string[] args)
        {
            try
            {
                using (Document doc = new Document())
                {
                    doc.RegistrationName = "demo";
                    doc.RegistrationKey  = "demo";

                    doc.Load("sample.pdf");

                    // Prepare simple template (for example, a logo) and draw it on every page
                    // Create template of specified size
                    GraphicsTemplate headerTemplate = new GraphicsTemplate(250, 50);
                    headerTemplate.DrawString("Here is a header text", new Font(StandardFonts.CourierBold, 15), new SolidBrush(), 30, 10);

                    GraphicsTemplate footerTemplate = new GraphicsTemplate(250, 50);
                    footerTemplate.DrawString("Here is the footer text", new Font(StandardFonts.CourierBold, 15), new SolidBrush(), 30, 10);

                    // Write template in each pages
                    for (int i = 0; i < doc.Pages.Count; i++)
                    {
                        Page currentPage = doc.Pages[i];
                        currentPage.Canvas.DrawTemplate(headerTemplate, 40, 10);
                        currentPage.Canvas.DrawTemplate(footerTemplate, 350, (currentPage.Height - 40));
                    }

                    // Save output file
                    doc.Save("result.pdf");
                }

                // Open result document in default associated application (for demo purpose)
                ProcessStartInfo processStartInfo = new ProcessStartInfo("result.pdf");
                processStartInfo.UseShellExecute = true;
                Process.Start(processStartInfo);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine("Press enter key to exit...");
            Console.ReadLine();
        }
Exemplo n.º 21
0
        private void drawSpacesCells(GraphicsTemplate xObj)
        {
            if (BorderColor != null)
            {
                float w   = getRotateWidth() / MaxLength;
                Pen   pen = new SolidPen(BorderColor);
                if (BorderStyle == BorderStyle.Dashed)
                {
                    pen.DashPattern = new DashPattern(new float[] { 3 });
                }

                float curPos = 0;
                for (int i = 1; i < MaxLength; ++i)
                {
                    curPos += w;
                    xObj.DrawLine(pen, curPos, 0, curPos, Height);
                }
            }
        }
Exemplo n.º 22
0
        static void Main(string[] args)
        {
            try
            {
                using (Document pdfDocument = new Document())
                {
                    pdfDocument.RegistrationName = "demo";
                    pdfDocument.RegistrationKey  = "demo";

                    pdfDocument.Load("sample.pdf");

                    Page page = pdfDocument.Pages[0];

                    // copy page content as template
                    GraphicsTemplate template = page.SaveAsTemplate();

                    // create new page of required size
                    Page newPage = new Page(PaperFormat.A4);
                    // draw the stored template on the new page with required offset
                    newPage.Canvas.DrawTemplate(template, 50, 50);

                    // replace the old page with the new one
                    pdfDocument.Pages.Remove(0);
                    pdfDocument.Pages.Add(newPage);

                    //Save output file
                    pdfDocument.Save("result.pdf");
                }

                // Open result document in default associated application (for demo purpose)
                ProcessStartInfo processStartInfo = new ProcessStartInfo("result.pdf");
                processStartInfo.UseShellExecute = true;
                Process.Start(processStartInfo);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine("Press any key to exit...");
            Console.ReadLine();
        }
Exemplo n.º 23
0
        static void Main()
        {
            // Create new document
            Document pdfDocument = new Document();

            pdfDocument.RegistrationName = "demo";
            pdfDocument.RegistrationKey  = "demo";

            // If you wish to load an existing document uncomment the line below and comment the Add page section instead
            // pdfDocument.Load(@".\existing_document.pdf");

            // Prepare simple template (for example, a logo) and draw it on every page

            // Create template of specified size
            GraphicsTemplate template = new GraphicsTemplate(250, 50);

            // Draw the logo
            template.DrawRectangle(new SolidBrush(new ColorRGB(192, 192, 255)), 0, 0, 250, 50);
            template.DrawString("My Company Logo", new Font(StandardFonts.TimesBoldItalic, 24), new SolidBrush(), 30, 10);

            // Add few pages and draw the prepared template on each one
            for (int i = 0; i < 3; i++)
            {
                Page page = new Page(PaperFormat.A4);
                page.Canvas.DrawTemplate(template, 10, 10);
                pdfDocument.Pages.Add(page);
            }

            // Save document to file
            pdfDocument.Save("result.pdf");

            // Cleanup
            pdfDocument.Dispose();

            // Open result document in default associated application (for demo purpose)
            ProcessStartInfo processStartInfo = new ProcessStartInfo("result.pdf");

            processStartInfo.UseShellExecute = true;
            Process.Start(processStartInfo);
        }
Exemplo n.º 24
0
        private int EnhMetaFileProc(IntPtr hdc, IntPtr lpHTable, IntPtr lpEFMR, int nObj, IntPtr lpData)
        {
            GDI32.EMR emr = (GDI32.EMR)Marshal.PtrToStructure(lpEFMR, typeof(GDI32.EMR));
            switch (emr.iType)
            {
            case GDI32.EMR_HEADER:
                GDI32.ENHMETAHEADER emh = (GDI32.ENHMETAHEADER)Marshal.PtrToStructure(lpEFMR, typeof(GDI32.ENHMETAHEADER));
                uint width  = (uint)((float)Math.Abs(emh.rclFrame.right - emh.rclFrame.left) * (float)emh.szlDevice.cx * 10.0f / ((float)emh.szlMillimeters.cx * 1000.0f));
                uint height = (uint)((float)Math.Abs(emh.rclFrame.bottom - emh.rclFrame.top) * (float)emh.szlDevice.cy * 10.0f / ((float)emh.szlMillimeters.cy * 1000.0f));
                _graphicsTemplate = new GraphicsTemplate(width, height);
                break;

            case GDI32.EMR_ARCTO:
                GDI32.EMRARCTO emrArc = (GDI32.EMRARCTO)Marshal.PtrToStructure(lpEFMR, typeof(GDI32.EMRARCTO));
                _graphicsTemplate.DrawArc(new SolidPen(), (float)(emrArc.rclBox.right - emrArc.rclBox.left) / 2, (float)(emrArc.rclBox.bottom - emrArc.rclBox.top) / 2, (float)(emrArc.rclBox.right - emrArc.rclBox.left) / 2, (float)(emrArc.rclBox.bottom - emrArc.rclBox.top) / 2, 0, 270);
                break;

            case GDI32.EMR_EOF:
                break;
            }
            return(1);
        }
Exemplo n.º 25
0
        private void drawTick(GraphicsTemplate xObj)
        {
            StringFormat format = new StringFormat();

            format.HorizontalAlign = HorizontalAlign.Center;
            format.VerticalAlign   = VerticalAlign.Center;

            Brush br;

            if (BorderColor == null)
            {
                br = new SolidBrush(new ColorRGB(0, 0, 0));
            }
            else
            {
                br = new SolidBrush(BorderColor);
            }

            float fontSize = Math.Min(Width, Height) - 2;
            Font  fnt      = new Font(StandardFonts.ZapfDingbats, fontSize);

            xObj.DrawString("4", fnt, br, new RectangleF(0, 0, Width, Height), format);
        }
Exemplo n.º 26
0
        private void drawOnelineText(string text, GraphicsTemplate xObj)
        {
            float left = Border.Width * 2;

            if (Border.Style == BorderStyle.Beveled || Border.Style == BorderStyle.Inset)
            {
                left *= 2;
            }

            if (Font.Size == 0)
            {
                int   w    = (int)Width; // 72 pixels per inch
                Font  tf   = new Font(Font.Name, 12, Font.Bold, Font.Italic, Font.Underline, Font.Strikeout);
                float step = 0.5f;
                while (tf.GetTextWidth(text) > w && tf.Size > 4 + step)
                {
                    tf.Size -= step;
                }
                Font.Size = tf.Size;
                if (this.Dictionary["DA"] != null)
                {
                    this.Dictionary.RemoveItem("DA");
                }
            }

            StringFormat format = new StringFormat();

            format.VerticalAlign = VerticalAlign.Center;
            float y = getRotateHeight() / 2 - Font.GetTextHeight() / 2;

            if (TextAlign == TextAlign.Left)
            {
                format.HorizontalAlign = HorizontalAlign.Left;
                xObj.DrawString(text, Font, new SolidBrush(FontColor), left, y, format);
            }
            else if (TextAlign == TextAlign.Center)
            {
                if (Font.GetTextWidth(text) <= getRotateWidth() - 4 * left + 1.0f)
                {
                    format.HorizontalAlign = HorizontalAlign.Center;
                    xObj.DrawString(text, Font, new SolidBrush(FontColor), new RectangleF(0, 0, getRotateWidth(), getRotateHeight()), format);
                }
                else
                {
                    format.HorizontalAlign = HorizontalAlign.Left;
                    xObj.DrawString(text, Font, new SolidBrush(FontColor), left, y, format);
                }
            }
            else if (TextAlign == TextAlign.Right)
            {
                if (Font.GetTextWidth(text) <= getRotateWidth() - 4 * left + 1.0f)
                {
                    format.HorizontalAlign = HorizontalAlign.Right;
                    xObj.DrawString(text, Font, new SolidBrush(FontColor), new RectangleF(left, 0, getRotateWidth() - 2 * left, getRotateHeight()), format);
                }
                else
                {
                    format.HorizontalAlign = HorizontalAlign.Left;
                    xObj.DrawString(text, Font, new SolidBrush(FontColor), left, y, format);
                }
            }
        }