Exemple #1
0
        private static void DrawSmallText(Graphics g, ImageText smallText, EnumImageStyle style, EnumImageType type, ImageFont imageFont)
        {
            FontFamily font = null;

            if (!imageFont.ifSystem)
            {
                //读取字体文件
                string path = AppDomain.CurrentDomain.BaseDirectory + imageFont.url;
                PrivateFontCollection pfc = new PrivateFontCollection();
                pfc.AddFontFile(path);
                font = pfc.Families[0];
            }
            else
            {
                font = new FontFamily(imageFont.name);
            }
            string drawString = "";

            if (smallText.Order)
            {
                drawString = smallText.Text; // Create font and brush.
            }
            else //反向打印
            {
                drawString = WebApplication.Common.Utils.ReverseCharArray(smallText.Text);
            }
            Font       drawFont = new Font(font, smallText.FontSize); //实例化字体
            SolidBrush drawBrush;
            float      x = smallText.PositionX; float y = smallText.PositionY;

            if (type == EnumImageType.儿童印章)
            {
                drawBrush = new SolidBrush(Color.Black);
            }
            else
            {
                if (style == EnumImageStyle.阳文)
                {
                    drawBrush = new SolidBrush(Color.Red);
                }
                else
                {
                    drawBrush = new SolidBrush(Color.White);
                }
            }
            g.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
            g.TextRenderingHint  = System.Drawing.Text.TextRenderingHint.AntiAlias;
            g.DrawString(drawString, drawFont, drawBrush, x, y);
        }
Exemple #2
0
        //private static void DrawMainText(Graphics g, ImageText mainText, EnumImageStyle style, EnumImageType type)
        //{
        //    FontFamily font = null;
        //    if (!mainText.imageFont.ifSystem)
        //    {
        //        //读取字体文件
        //        string path = AppDomain.CurrentDomain.BaseDirectory + mainText.imageFont.url;
        //        PrivateFontCollection pfc = new PrivateFontCollection();
        //        pfc.AddFontFile(path);
        //        font = pfc.Families[0];
        //    }
        //    else
        //    {
        //        font = new FontFamily(mainText.imageFont.name);
        //    }

        //    String drawString = mainText.Text; // Create font and brush.

        //    Font drawFont = new Font(font, mainText.FontSize);    //实例化字体
        //    SolidBrush drawBrush;
        //    float x = mainText.PositionX, y = mainText.PositionY;
        //    if (type == EnumImageType.儿童印章)
        //    {
        //        drawBrush = new SolidBrush(Color.Black); //儿童印章不区分阴文和阳文,统一用黑色文字。
        //    }
        //    else
        //    {
        //        if (style == EnumImageStyle.阳文)
        //        {
        //            drawBrush = new SolidBrush(Color.Red);
        //        }
        //        else
        //        {
        //            drawBrush = new SolidBrush(Color.White);
        //        }
        //    }
        //    ////减缓锯齿
        //    g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
        //    g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
        //    g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
        //    g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
        //    g.DrawString(drawString, drawFont, drawBrush, x, y);
        //}

        //private static void DrawSmallText(Graphics g, ImageText smallText, EnumImageStyle style, EnumImageType type)
        //{
        //    FontFamily font = null;
        //    if (!smallText.imageFont.ifSystem)
        //    {
        //        //读取字体文件
        //        string path = AppDomain.CurrentDomain.BaseDirectory + smallText.imageFont.url;
        //        PrivateFontCollection pfc = new PrivateFontCollection();
        //        pfc.AddFontFile(path);
        //        font = pfc.Families[0];
        //    }
        //    else
        //    {
        //        font = new FontFamily(smallText.imageFont.name);
        //    }
        //    string drawString = "";
        //    if (smallText.Order)
        //    {
        //        drawString = smallText.Text; // Create font and brush.
        //    }
        //    else //反向打印
        //    {
        //        drawString = WebApplication.Common.Utils.ReverseCharArray(smallText.Text);
        //    }
        //    Font drawFont = new Font(font, smallText.FontSize); //实例化字体
        //    SolidBrush drawBrush;
        //    float x = smallText.PositionX; float y = smallText.PositionY;
        //    if (type == EnumImageType.儿童印章)
        //    {
        //        drawBrush = new SolidBrush(Color.Black);
        //    }
        //    else
        //    {
        //        if (style == EnumImageStyle.阳文)
        //        {
        //            drawBrush = new SolidBrush(Color.Red);
        //        }
        //        else
        //        {
        //            drawBrush = new SolidBrush(Color.White);
        //        }
        //    }
        //    g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
        //    g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
        //    g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
        //    g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
        //    g.DrawString(drawString, drawFont, drawBrush, x, y);
        //}
        #endregion

        //5-19需求修改,一个印章只有一个字体
        private static void DrawMainText(Graphics g, ImageText mainText, EnumImageStyle style, EnumImageType type, ImageFont imageFont)
        {
            FontFamily font = null;

            if (!imageFont.ifSystem)
            {
                //读取字体文件
                string path = AppDomain.CurrentDomain.BaseDirectory + imageFont.url;
                PrivateFontCollection pfc = new PrivateFontCollection();
                pfc.AddFontFile(path);
                font = pfc.Families[0];
            }
            else
            {
                font = new FontFamily(imageFont.name);
            }

            String drawString = mainText.Text;                       // Create font and brush.

            Font       drawFont = new Font(font, mainText.FontSize); //实例化字体
            SolidBrush drawBrush;
            float      x = mainText.PositionX, y = mainText.PositionY;

            if (type == EnumImageType.儿童印章 || type == EnumImageType.个性签名章)
            {
                drawBrush = new SolidBrush(Color.Black); //儿童印章和个性签名章 不区分阴文和阳文,统一用黑色文字。
            }
            else
            {
                if (style == EnumImageStyle.阳文)
                {
                    drawBrush = new SolidBrush(Color.Red);
                }
                else
                {
                    drawBrush = new SolidBrush(Color.White);
                }
            }
            ////减缓锯齿
            g.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
            g.TextRenderingHint  = System.Drawing.Text.TextRenderingHint.AntiAlias;
            g.DrawString(drawString, drawFont, drawBrush, x, y);
        }