Пример #1
0
        public static void Main()
        {
            var encoder = new BarcodeEncoder();
            var reader  = new BarcodeReader {
                Options = { PossibleFormats = new[] { BarcodeFormat.CODE_128 } }
            };

            var count = 0;

            foreach (var text in CreateTexts(25, 4000))
            {
                if (!encoder.TryEncode(text, out var codes))
                {
                    throw new Exception("Failed to encode " + text);
                }

                var barcode = new BarcodePainter(codes);
                using (var bitmap = barcode.Draw(3, 42))
                {
                    var decoded = reader.Decode(bitmap);
                    if (decoded.Text != text)
                    {
                        throw new Exception("Encoded " + text + " but read " + decoded.Text);
                    }
                }

                Console.Write($"\rTested {++count} codes");
            }

            Console.WriteLine();
        }
Пример #2
0
        public void EncodeUserSet(BarcodeEncoder encoder)
        {
            Items item = CbError.SelectedItem as Items;
            if (item != null)
            {
                switch (item.K)
                {
                    case "L":
                        encoder.ErrorCorrectionLevel = ErrorCorrectionLevel.L;
                        break;
                    case "M":
                        encoder.ErrorCorrectionLevel = ErrorCorrectionLevel.M;
                        break;
                    case "Q":
                        encoder.ErrorCorrectionLevel = ErrorCorrectionLevel.Q;
                        break;
                    case "H":
                        encoder.ErrorCorrectionLevel = ErrorCorrectionLevel.H;
                        break;
                }
            }

            item = CbCoding.SelectedItem as Items;
            if (item != null)
            {
                encoder.CharacterSet = item.K;
            }
            encoder.ForeColor = BtForeColor.BackColor;
            encoder.BackColor = BtBackColor.BackColor;
            encoder.QuietZone = 1;
            encoder.Width = (int)SpDimW.Value;
            encoder.Height = (int)SpDimH.Value;
        }
Пример #3
0
        private void Btn_crear_Click(object sender, EventArgs e)
        {
            int iAux;

            try
            {
                if (int.TryParse(Txt_texto.Text, out iAux))
                {
                    Er_validar.SetError(Txt_texto, "");
                    Crear = new BarcodeEncoder();
                    Crear.IncludeLabel = true;
                    Crear.CustomLabel  = Txt_texto.Text;
                    if (Txt_texto.Text != "")
                    {
                        Pic_img.Image = new Bitmap(Crear.Encode(BarcodeFormat.Code39, Txt_texto.Text));
                    }
                }
                else
                {
                    Er_validar.SetError(Txt_texto, "Solo números se acepta");
                }
            }catch (Exception ex)
            {
                MessageBox.Show("Dato invalido: " + ex.Message);
            }
        }
Пример #4
0
 private void button2_Click(object sender, EventArgs e)
 {
     Generator = new BarcodeEncoder();
     Generator.IncludeLabel = true;
     Generator.CustomLabel  = textBox5.Text;
     if (textBox5.Text != "")
     {
         pictureBox1.Image = new Bitmap(Generator.Encode(BarcodeFormat.Code39, textBox5.Text));
     }
 }
Пример #5
0
        public FacultySubpage(DetailPage dp)
        {
            InitializeComponent();
            FacultyItems = new Dictionary<string, string[]>();
            FacultyQR = new Dictionary<string, ImageBrush>();

            detailPage = dp;
            LoadFacultyData();
            GenerateButtons();

            // Create the QR code builder.
            qrEncoder = new BarcodeEncoder();
        }
Пример #6
0
        public static void Main(string[] args)
        {
            var text = args.Length > 0 ? args[0] : "test";

            if (BarcodeEncoder.TryEncodeBarcode(text, out var codes))
            {
                using (var bitmap = BarcodePainter.Draw(codes, 1, 20))
                {
                    bitmap.Save("output.png", ImageFormat.Png);
                }
            }
            else
            {
                throw new Exception($"The text {text} contains unsupported characters.");
            }
        }
Пример #7
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (!ValidateData())
            {
                MessageBox.Show("Ensure you enter all detail"); return;
            }

            try
            {
                string str = txtName.text.Substring(0, 3).ToUpper();
                string cat = ddlCategory.selectedIndex.ToString();
                Generator = new BarcodeEncoder();
                Generator.IncludeLabel = true;

                string code = str + txtPrice.text + txtQuantity.text;
                Generator.CustomLabel = code;
                picBoxBarcode.Image   = new Bitmap(Generator.Encode(BarcodeFormat.Code39, code));
                Barcode barcode = new Barcode()
                {
                    Barcode1 = code,
                    IsUsed   = true
                };
                unitOfWork.BarcodeRepository.Insert(barcode);
                unitOfWork.Save();
                btnPrint.Visible = true;

                Product p = new Product()
                {
                    Prod_Name   = txtName.text,
                    Price       = Convert.ToDecimal(txtPrice.text),
                    Quantity    = Convert.ToInt16(txtQuantity.text),
                    Barcode     = code,
                    Category_Id = Convert.ToInt16(cat)
                };
                unitOfWork.ProductRepository.Insert(p);
                unitOfWork.Save();
                MessageBox.Show("Product Added Successfullys");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Occured, Unable to generate Barcode");
            }
        }
Пример #8
0
        /// <summary>
        /// generate a barcode starts with MESCAP then followed with a random 8-digit number, then save it
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">event args</param>
        private void barcodeBT_Click(object sender, EventArgs e)
        {
            BarcodeEncoder generator = new BarcodeEncoder();
            string         ramdomNum = new Random().Next(0, 99999999).ToString();
            string         code      = "MESCAP" + ramdomNum;

            saveDialog = new SaveFileDialog();

            generator.IncludeLabel = true;
            generator.CustomLabel  = "MESCAP" + ramdomNum;
            WriteableBitmap image = generator.Encode(BarcodeFormat.Code39, code);

            saveDialog.Filter = "PNG File|*png";
            if (saveDialog.ShowDialog() == DialogResult.OK)
            {
                FileStream       stream        = new FileStream(saveDialog.FileName, FileMode.Create);
                PngBitmapEncoder bitmapEncoder = new PngBitmapEncoder();
                bitmapEncoder.Frames.Add(BitmapFrame.Create(image));
                bitmapEncoder.Save(stream);
                MessageBox.Show("Successfully saved!");
            }
        }
Пример #9
0
        private void btnGenarate_Click(object sender, EventArgs e)
        {
            string year        = DateTime.Now.ToString("yyyy");
            string BarcodeName = cmbYear.Text + cmbMonth.Text + "";

            try
            {
                for (int i = 1; i <= Convert.ToInt64(txtCount.Text); i++)
                {
                    Genarate = new BarcodeEncoder();
                    Genarate.IncludeLabel = true;
                    if (txtpath.Text != "")
                    {
                        PcBox.Image = new Bitmap(Genarate.Encode(BarcodeFormat.Code128, BarcodeName + i.ToString()));
                        PcBox.Image.Save(@"" + txtpath.Text + i.ToString() + ".jpg", ImageFormat.Jpeg);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #10
0
        public void VeryLongString()
        {
            BarcodeEncoder.TryEncodeBarcode(@"
ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890
ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890
ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890
ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890
ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890
ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890
ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890
ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890
ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890
ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890
ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890
ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890
ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890
ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890
ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890
ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890
ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890
ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890
ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890
ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890ThisIsATest1234567890", out _);
        }
Пример #11
0
        private void btn_incode_Click(object sender, EventArgs e)
        {
            try
            {
                string _maHang  = dgv_hang.CurrentRow.Cells["Column1"].Value.ToString();
                string _HauTo   = _maHang.Replace(MaHang, "");
                string _TenHang = dgv_hang.CurrentRow.Cells["TenMH"].Value.ToString() + _HauTo;
                string _gia     = "Giá : " + dgv_hang.CurrentRow.Cells["Gia"].Value.ToString().Replace(".000", "") + " VNĐ";

                MaVach_Sp mv = new MaVach_Sp();

                BarcodeEncoder Generator = new BarcodeEncoder();
                Generator.IncludeLabel = true;// hiện dòng label

                mv.lab_Ten.Text         = _TenHang;
                mv.img_code.ImageSource = new ImageSource(new Bitmap(Generator.Encode(BarcodeFormat.Code128, _maHang)));
                mv.lab_gia.Text         = _gia;


                ReportPrintTool report = new ReportPrintTool(mv);
                report.ShowPreview();
            }
            catch { }
        }
Пример #12
0
        private void BtEnc_Click(object sender, EventArgs e)
        {
            if (!_IOpt.Check())
            {
                return;
            }

            string text = _IOpt.Encode();
            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            if (_Encoder == null)
            {
                _Encoder = new BarcodeEncoder();
            }

            UcUserSet.EncodeUserSet(_Encoder);

            try
            {
                PbIcon.BackColor = _Encoder.BackColor;
                PbIcon.Image = _Encoder.Encode(BarcodeFormat.QRCode, text);
            }
            catch (Exception exp)
            {
                LbEcho.Text = exp.Message;
            }
        }
Пример #13
0
        private static void FillPDF(Dictionary <string, string> submittedFields, PdfDocument PDFDocument)
        {
            if (PDFDocument == null || PDFDocument.AcroForm == null)
            {
                throw new Exception("No PDF with fillable form submitted");
            }

            PdfAcroForm af = PDFDocument.AcroForm;


            //make sure fields are enabled
            if (af.Elements.ContainsKey(PdfAcroForm.Keys.NeedAppearances))
            {
                af.Elements[PdfAcroForm.Keys.NeedAppearances] = new PdfSharp.Pdf.PdfBoolean(true);
            }
            else
            {
                af.Elements.Add(PdfAcroForm.Keys.NeedAppearances, new PdfSharp.Pdf.PdfBoolean(true));
            }


            //Turn on unicode support
            XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode);

            //foreach (PDFField sField in submittedFields)
            foreach (KeyValuePair <string, string> sField in submittedFields)
            {
                try {
                    var field = af.Fields[sField.Key];
                    if (field is PdfTextField && (!sField.Key.EndsWith("_QRFill") && !sField.Key.EndsWith("_Code39Fill") && !sField.Key.EndsWith("_PDF417Fill")))
                    {
                        // filling in a text field
                        PdfTextField tf = (PdfTextField)field;

                        tf.ReadOnly = false;
                        if (Helper.IsChinese(sField.Value)) //override font if chinese is detected.
                        {
                            if (true)                       // remove evenatully - was used for switching different rendering methods
                            {
                                //Note: This will work for text Fields.. but make sure they are not linked (ie. multiple fileds with same name)
                                // If you want to make this more generic for all form fields you need to account for the possilbility
                                // that a form field could have several phyical outputs across multiple pages.  You can find the same
                                // properties but you need to check the KIDS collection for the field.  When there is only one display
                                // for a form field then the properties are rolled up to the form field itself - so the below works.
                                PdfRectangle rect = field.Elements.GetRectangle("/Rect");

                                if (tf.HasKids)
                                {
                                    throw new Exception("Multiple render locations found for text field" + sField.Key + ".  This can be supported, or just create separate fields for now.");
                                }

                                tf.Value = new PdfSharp.Pdf.PdfString(sField.Value, PdfStringEncoding.Unicode);

                                //also a bit of pain to locate the acutaly page the field is on... but OK.
                                XGraphics gfx = null;
                                foreach (var page in PDFDocument.Pages)
                                {
                                    if (page.Reference == field.Elements["/P"])
                                    {
                                        if (gfx != null)   //dispose of object before getting a new one.  Should actually never happen... but better safe than sorry....
                                        {
                                            gfx.Dispose();
                                        }
                                        gfx = XGraphics.FromPdfPage(page);
                                        break;
                                    }
                                }


                                XFont targetFont = new XFont("MicrosoftJhengHei", tf.Font.Size, XFontStyle.Regular, options);   //It's "KaigenSansSC" behind the scenes, but this may help with some rendering....
                                // Draw the text over the field
                                gfx.DrawString(sField.Value, targetFont, XBrushes.Black, new XRect(Math.Min(rect.X1, rect.X2), gfx.PageSize.Height - Math.Min(rect.Y1, rect.Y2) - Math.Abs(rect.Height), Math.Abs(rect.Width), Math.Abs(rect.Height)), XStringFormats.TopLeft);
                                gfx.Dispose();

                                //Theb hide the field
                                if (tf.Elements.ContainsKey("/F") == true)
                                {
                                    tf.Elements.SetInteger("/F", 6);
                                }


                                //original filling routine.. still kept here for refernce ... and since it will allow extracting form values from the PDF later.
                                tf.Font = targetFont;   // this is and the below is necessary to set both the view and edit font of the field.

                                if (tf.Elements.ContainsKey("/DA") == false)
                                {
                                    tf.Elements.Add(PdfTextField.Keys.DA, new PdfString($"/{targetFont.Name} {targetFont.Size} Tf 0 g"));
                                }
                                else
                                {
                                    tf.Elements[PdfTextField.Keys.DA] = new PdfString($"/{targetFont.Name} {targetFont.Size} Tf 0 g");
                                }
                            }
                        }
                        tf.Value = new PdfSharp.Pdf.PdfString(sField.Value, PdfStringEncoding.Unicode);
                    }
                    else if (field is PdfCheckBoxField)
                    {
                        if (sField.Value != null && sField.Value.Equals("TRUE", StringComparison.InvariantCultureIgnoreCase))
                        {
                            ((PdfCheckBoxField)field).Checked = true;
                        }
                        else
                        {
                            ((PdfCheckBoxField)field).Checked = false;
                        }
                    }
                    else if (field is PdfComboBoxField)
                    {
                        ((PdfComboBoxField)field).Value = new PdfString(sField.Value);
                    }
                    else if (field is PdfRadioButtonField)
                    {
                        ((PdfRadioButtonField)field).Value = new PdfName(sField.Value);
                    }
                    else if (field is PdfListBoxField)
                    {
                        string[] items = sField.Value.Split(",");
                        //PdfSharp.Pdf.PdfArray paNew = new PdfSharp.Pdf.PdfArray();
                        PdfArray pas = (PdfArray)(((PdfListBoxField)field).Value);
                        //PdfItem[] pis = pas.Elements.Items;
                        pas.Elements.Clear();
                        foreach (string sitem in items)

                        {
                            pas.Elements.Add(new PdfString(sitem));
                        }


                        //PdfListBoxField pl = (PdfListBoxField)field;
                        //PdfSharp.Pdf.PdfArray pa = (PdfSharp.Pdf.PdfArray)pl.Value;
                        //string values = "";
                        //foreach (PdfString pi in pa.Elements.Items)
                        //{
                        //    if (values.Length > 0) values += ", ";
                        //    values += pi.Value;
                        //}
                        //dictPDFFields.Add(key, values);
                    }
                    else if (field is PdfSignatureField)
                    {
                        if (sField.Value == "")
                        {
                            continue;
                        }

                        //Note: The below wroks because a named singature fields only appear once in a document.
                        // If you want to make this more generic for all form fields you need to account for the possilbility
                        // that a form field could have several phyical outputs across multiple pages.  You can find the same
                        // properties but you need to check the KIDS collection for the field.  When there is only one display
                        // for a form field then the properties are rolled up to the form field itself - so the below works.
                        PdfSignatureField sig = (PdfSignatureField)field;
                        OverlayImageOnField(PDFDocument, sField.Value, sig.Elements.GetRectangle("/Rect"), sig.Elements["/P"]);
                    }
                    else if (field is PdfTextField && (sField.Key.EndsWith("_QRFill") || sField.Key.EndsWith("_Code39Fill") || sField.Key.EndsWith("_PDF417Fill")))
                    {
                        if (sField.Value == "")
                        {
                            continue;
                        }

                        //Note: This will work for text Fields.. but make sure they are not linked (ie. multiple fileds with same name)
                        // If you want to make this more generic for all form fields you need to account for the possilbility
                        // that a form field could have several phyical outputs across multiple pages.  You can find the same
                        // properties but you need to check the KIDS collection for the field.  When there is only one display
                        // for a form field then the properties are rolled up to the form field itself - so the below works.
                        PdfRectangle rect = field.Elements.GetRectangle("/Rect");

                        PdfTextField tf = (PdfTextField)field;

                        if (tf.HasKids)
                        {
                            throw new Exception("Multiple render locations found on barcode fill.  This can be supported, or just create separate fields for now.");
                        }

                        tf.Value = new PdfSharp.Pdf.PdfString(sField.Value, PdfStringEncoding.Unicode);

                        //This hides the field
                        if (tf.Elements.ContainsKey("/F") == true)
                        {
                            tf.Elements.SetInteger("/F", 6);
                        }

                        MessagingToolkit.Barcode.BarcodeEncoder benc = new BarcodeEncoder();
                        benc.Width  = Convert.ToInt32((rect.X2 - rect.X1) * 5); //I just made up that rule - but seems to work well for laser printers.
                        benc.Height = Convert.ToInt32((rect.Y2 - rect.Y1) * 5);

                        if (sField.Key.EndsWith("_Code39Fill"))
                        {
                            benc.Encode(BarcodeFormat.Code39, sField.Value);
                        }
                        else if (sField.Key.EndsWith("_PDF417Fill"))
                        {
                            benc.Encode(BarcodeFormat.PDF417, sField.Value);
                        }
                        else                                                                                            //_QRFill
                        {
                            benc.ErrorCorrectionLevel = MessagingToolkit.Barcode.QRCode.Decoder.ErrorCorrectionLevel.M; //M=15%  H=25% L=7% (default)
                            benc.Encode(BarcodeFormat.QRCode, sField.Value);
                        }

                        byte[] qrCodeAsPngByteArr = benc.GetImageData(SaveOptions.Png);
                        OverlayImageOnField(PDFDocument, qrCodeAsPngByteArr, rect, field.Elements["/P"]);
                    }
                } catch (Exception e) {
                    throw new Exception("Fill of Field '" + sField.Key + "' ('" + sField.Value + "') failed.  " + e.Message);
                }
            }
        }
Пример #14
0
 public void NumericBarcode()
 {
     BarcodeEncoder.TryEncodeBarcode("1234567890", out _);
 }
Пример #15
0
 public void CodesetChanges()
 {
     BarcodeEncoder.TryEncodeBarcode("ThisIsATest1234567890", out _);
 }
Пример #16
0
 public void TextBarcode()
 {
     BarcodeEncoder.TryEncodeBarcode("ThisIsATest", out _);
 }
Пример #17
0
        public string ExportQrc(string src, string dst)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(src);

            XmlNode node = doc.SelectSingleNode("/amon/card/base");
            string path = ReadString(node, "path", "Card");
            if (!Path.IsPathRooted(path))
            {
                path = Path.Combine(_Root, path);
            }

            node = doc.SelectSingleNode("/amon/card/template-uri");
            if (node == null)
            {
                return null;
            }
            src = node.InnerText;
            if (!CharUtil.IsValidate(src))
            {
                return null;
            }

            StringBuilder buffer = new StringBuilder();
            _Text(buffer, Path.Combine(path, src));
            _Trim(buffer);

            try
            {
                BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
                barcodeEncoder.CharacterSet = "UTF-8";
                barcodeEncoder.ErrorCorrectionLevel = ErrorCorrectionLevel.L;
                barcodeEncoder.ForeColor = Color.Black;
                barcodeEncoder.BackColor = Color.White;
                barcodeEncoder.QuietZone = 1;
                barcodeEncoder.Width = 160;
                barcodeEncoder.Height = 160;
                Image img = barcodeEncoder.Encode(BarcodeFormat.QRCode, buffer.ToString());

                Att item = _SafeModel.GetAtt(Att.PWDS_HEAD_META);
                dst = Path.Combine(dst, item.Text + ".jpg");

                img.Save(dst, ImageFormat.Jpeg);
                return dst;
            }
            catch (Exception exp)
            {
                Main.LogInfo(exp.Message);
                return null;
            }
        }
Пример #18
0
        /// <summary>
        /// 打印二维条码
        /// </summary>
        /// <param name="g1">画图对象</param>
        /// <param name="conntent">打印内容</param>
        /// <param name="point">打印的坐标</param>
        private void drawQRCode(Graphics g1, string content, PointF point)
        {

            BarcodeEncoder barcodeEncoder = new BarcodeEncoder();
            barcodeEncoder.CharacterSet = "ISO-8859-1";
            barcodeEncoder.ErrorCorrectionLevel = MessagingToolkit.Barcode.QRCode.Decoder.ErrorCorrectionLevel.M;
            barcodeEncoder.ForeColor = System.Drawing.Color.Black;
            barcodeEncoder.BackColor = System.Drawing.Color.White;
            barcodeEncoder.QuietZone = 4;
            barcodeEncoder.Width = 90;
            barcodeEncoder.Height = 90;
            Image QRimage = barcodeEncoder.Encode(BarcodeFormat.QRCode, content);

            //二维大小为70f
            g1.DrawImage(QRimage, point.X, point.Y, 70f, 70f);
        }