C#打印DM碼

需要準備打印二維碼的庫:DataMatrix.net.dll

DataMatrix.net.dll下載地址:https://sourceforge.net/projects/datamatrixnet/files/rel0.4/rel0.4.4/

文字轉二維碼代碼實現如下:

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {               
                string content = "1552458000";
                Image image = Encode_DM(content, 2, 2);
                pictureBox1.Image = image;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }

        public Bitmap Encode_DM(string content, int moduleSize = 5, int margin = 5)
        {
            DmtxImageEncoderOptions opt = new DmtxImageEncoderOptions();
            opt.ModuleSize = moduleSize;
            opt.MarginSize = margin;

            DmtxImageEncoder encoder = new DmtxImageEncoder();

            Bitmap bm = encoder.EncodeImage(content, opt);
            return bm;
        }

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章