如何打印在C#中的条形码格式 [英] How to print the Barcode format in c#

查看:486
本文介绍了如何打印在C#中的条形码格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我使用的显示从数据库中的列,现在我想打印条形码格式的radgridview。我得先列值转换成位图,然后在页面上显示的内容,我也想打印在单页上的radgridview的每一行,然后。

I have a radgridview in which I am using the displaying a column from the database and now I want print the BarCode format. I have to first convert the column values into the Bitmap and then display the content on the page and I also want to print each row of the radgridview on a single page and then.

我有这样一个gridview,我使用的字体免费3 9的显示这样的:

I have a gridView like this, I am using font Free 3 of 9 to show this:

和我想打印这样的:

我要得到的列值,并将其转换成位图,并在页面上的打印。我不知道如何做到这一点。我怎么能转换成该列的值的格式图像中显示,然后我怎么打印每行条形码的单页上?

I have to get the Column value and convert it into the Bitmap and the print in on the page. I do not know how to do this. How can I convert the column value to the format showed in the image and then how can I print each row BarCode on a single page?

推荐答案

我已经张贴在你的另一个帖子点击此处查看答案。

i have posted the answer on your another post check it here.

如何添加名单,LT值;字符串>到List<&图片框GT;在C#中它编码为条码

    public Image stringToImage(string inputString)
    { 
        string text = inputString.Trim();

        Bitmap bmp = new Bitmap(1, 1);

        //Set the font style of output image
        Font font = new Font("Free 3 of 9", 25, FontStyle.Regular, GraphicsUnit.Pixel);
        Font font2 = new Font("Arial", 15, FontStyle.Regular, GraphicsUnit.Pixel);

        Graphics graphics = Graphics.FromImage(bmp);

        int width = (int)graphics.MeasureString(text, font).Width;
        int height = (int)graphics.MeasureString(text, font).Height;

        int height2 = (int)graphics.MeasureString(text, font2).Height;

        bmp = new Bitmap(bmp, new Size(width, height+height2));
        graphics = Graphics.FromImage(bmp);



        //Specify the background color of the image
        graphics.Clear(Color.Cyan);
        graphics.SmoothingMode = SmoothingMode.AntiAlias;
        graphics.TextRenderingHint = TextRenderingHint.AntiAlias;



        //Specify the text, font, Text Color, X position and Y position of the image
        graphics.DrawString(text, font, new SolidBrush(Color.Black), 0, 0);
        graphics.DrawString(text, font2, new SolidBrush(Color.Black), 0, height);

        graphics.Flush();
        graphics.Dispose();

        //if you want to save the image  uncomment the below line.
        //bmp.Save(@"d:\myimage.jpg", ImageFormat.Jpeg);

        return bmp;

这篇关于如何打印在C#中的条形码格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆