Asp.net uses the Zxing library for bar code output

Source: Internet
Author: User

This simple problem has plagued me for nearly two hours, mainly because I did not find a demo in the official document. I can only use the search engine to check the programs written by other programmers, however, it was found that there were pitfalls everywhere. I read four or five examples. None of them were able to run normally, and all of them reported errors. After more than an hour of trying, I finally got it done. Let's just move on to the code. The second step is to create An aspx file. The code in the background is as follows: using ZXing. common; 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" was written to death during the test, and can be replaced by variables. BarcodeFormat. CODE_39 and other parameters can be replaced with other parameters to generate bar codes of other formats. In this case, 1 is output on disk D. the main functions of jepg barcode image have been implemented here. The generated barcode image is as follows: scan the barcode function of the mobile phone and the result is exactly 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.