문제

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.

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

enter image description here

and I want to print it like 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? enter image description here

도움이 되었습니까?

해결책

enter image description here

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

How to Add the values of List<string> into the List<PictureBox> after encoding it to Barcode in 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;

you must have installed font "free 3 of 9"

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top