asp.net using zxing library to realize the realization of barcode output-practical skills

Source: Internet
Author: User

This simple question bothered me for nearly two hours, the main is the official document did not find the demo, that can only use search engines, see other programmers to write the program, but found everywhere is a pit, see four or five examples, no one can be normal operation, all the error, after one hours of trial, only to finish. Not much to say, directly on the screenshot and code.

First, add the Zxing.dll reference to the project (zxing.dll download address http://www.jb51.net/dll/zxing.dll.html)

The second is to create an ASPX file, in the background the code is as follows

Copy Code code as follows:

Using Zxing.common;
Using Zxing;
Using Zxing.rendering;
Using System.Drawing;
Using System.Drawing.Imaging;
Using ZXing.QrCode.Internal;

Namespace Zxingtm
{
public partial class Txm:System.Web.UI.Page
{
protected void Page_Load (object sender, EventArgs e)
{
Multiformatwriter mutiwriter = new Multiformatwriter ();
Bitmatrix BM = Mutiwriter.encode ("123456789", barcodeformat.code_39, 363, 150);
Bitmap img = new Barcodewriter (). Write (BM);
Img. Save ("D:/1.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
}

In the code "123456789" in the test I was written dead, use the time can be replaced with a variable. barcodeformat.code_39 and other parameters can be replaced by other, to generate other formats of the barcode

In this case, the output of the 1.JEPG barcode picture in D disk, where the main function has been achieved, the resulting barcode picture is as follows:


With the mobile phone with the scanning barcode function swept down, the result is 123456789

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.