public static void Run() { //ExStart:FNC1SecondPositionInExtendedMode // The path to the documents directory. string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes(); // Create codetext QrExtCodetextBuilder lTextBuilder = new QrExtCodetextBuilder(); lTextBuilder.AddFNC1SecondPosition("12"); lTextBuilder.AddPlainCodetext("TRUE3456"); // Generate codetext string lCodetext = lTextBuilder.GetExtendedCodetext(); // Instantiate barcode object and Set its CodeText, encoding mode, error correction level, display text and Symbology BarCodeBuilder builder = new BarCodeBuilder(lCodetext, EncodeTypes.QR); builder.QREncodeMode = QREncodeMode.ExtendedCodetext; builder.QRErrorLevel = QRErrorLevel.LevelL; builder.Display2DText = "My Text"; // Get barcode image Bitmap and Save QR code Bitmap lBmp = builder.GenerateBarCodeImage(); lBmp.Save(dataDir + "FNC1SecondPositionInExtendedMode_out.bmp", ImageFormat.Bmp); //ExEnd:FNC1SecondPositionInExtendedMode }
public static void Run() { //ExStart:MultiECIModeInExtendedMode // The path to the documents directory. string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes(); // Create codetext QrExtCodetextBuilder lTextBuilder = new QrExtCodetextBuilder(); lTextBuilder.AddECICodetext(ECIEncodings.Win1251, "Will"); lTextBuilder.AddECICodetext(ECIEncodings.UTF8, "Right"); lTextBuilder.AddECICodetext(ECIEncodings.UTF16BE, "Power"); lTextBuilder.AddPlainCodetext(@"t\e\\st"); // Generate codetext string lCodetext = lTextBuilder.GetExtendedCodetext(); // Initialize a BarCodeBuilder class object, Set CodeText, Symbology, Encoding mode, correction level and display text BarCodeBuilder builder = new BarCodeBuilder(lCodetext, EncodeTypes.QR); builder.QREncodeMode = QREncodeMode.ExtendedCodetext; builder.QRErrorLevel = QRErrorLevel.LevelL; builder.CodeText = lCodetext; builder.Display2DText = "My Text"; Bitmap lBmp = builder.GenerateBarCodeImage(); lBmp.Save(dataDir + "MultiECIModeInExtendedMode_out.bmp", ImageFormat.Bmp); //ExEnd:MultiECIModeInExtendedMode }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes(); // initialize a BarCodeBuilder class object BarCodeBuilder builder = new BarCodeBuilder(); // Set its Symbology builder.SymbologyType = Symbology.QR; // Set encoding mode builder.QREncodeMode = QREncodeMode.ECIEncoding; // Set ForceQR (default) for standard QR builder.QREncodeType = QREncodeType.ForceQR; // Set ECI encoding type builder.ECIEncoding = ECIEncodings.UTF8; // Set code text builder.CodeText = "12345TEXT"; // Set error correction level builder.QRErrorLevel = QRErrorLevel.LevelL; // Get barcode image Bitmap Bitmap lBmp = builder.GenerateBarCodeImage(); // Save QR code lBmp.Save(dataDir + "EncodeQRCodEInECIMode_out.bmp", ImageFormat.Bmp); }
protected void Button1_Click(object sender, EventArgs e) { int w = Convert.ToInt32(TextBox2.Text); int h = Convert.ToInt32(TextBox3.Text); string str = TextBox1.Value; lbl.InnerText = str.Length.ToString(); //var aa = new ServiceReference1.FirmForTMTResponse(); //create codetext QrExtCodetextBuilder lTextBuilder = new QrExtCodetextBuilder(); lTextBuilder.AddFNC1FirstPosition(); //lTextBuilder.AddPlainCodetext("000%89%%0"); lTextBuilder.AddPlainCodetext(str); lTextBuilder.AddFNC1GroupSeparator(); //lTextBuilder.AddPlainCodetext("12345<FNC1>"); //generate codetext string lCodetext = lTextBuilder.GetExtendedCodetext(); //generate BarCodeBuilder builder = new BarCodeBuilder(); // set its Symbology builder.SymbologyType = Symbology.QR; // set encoding mode builder.QREncodeMode = QREncodeMode.ExtendedCodetext; // set error correction level builder.QRErrorLevel = QRErrorLevel.LevelL; // set code text builder.CodeText = lCodetext; // set display text //builder.Display2DText = ""; builder.CodeLocation = Aspose.BarCode.CodeLocation.None; //builder.AutoSize = false; //builder.ImageHeight = 400; //builder.ImageWidth = 400; // get barcode image Bitmap Bitmap lBmp = builder.GenerateBarCodeImage(); //Bitmap lBmp = builder.GetCustomSizeBarCodeImage(new Size(100, 100), true); //Bitmap lBmp = builder.GetOnlyBarCodeImage(1); Graphics g1 = Graphics.FromImage(lBmp); g1.FillRectangle(Brushes.White, new Rectangle(0, 0, lBmp.Width, 12)); //Bitmap newlbmp = KiResizeImage(lBmp, w, h); // save QR code //newlbmp.Save(@"d:\test_qr.png", ImageFormat.Png); lBmp.Save(@"d:\test_qr.png", ImageFormat.Png); }
public static Image CreateBarCode(string codeText) { if (string.IsNullOrEmpty(codeText)) return null; BarCodeBuilder barcode = new BarCodeBuilder(codeText, Symbology.Code39Standard); barcode.BarHeight = 7.5f; barcode.xDimension = 0.2f; barcode.WideNarrowRatio = 1.8f; barcode.CodeTextAlignment = StringAlignment.Near; barcode.Resolution = new Resolution(300, 300, ResolutionMode.Printer); Image bitmap = barcode.GenerateBarCodeImage(); Bitmap sbitmap = new Bitmap(bitmap, new Size((int)(bitmap.Width), bitmap.Height)); return sbitmap; }
public static void Run() { // ExStart:OptionalExceptionMessageWith1DBarCode // Instantiate BarCodeBuilder object BarCodeBuilder builder = new BarCodeBuilder("348503498549085409", EncodeTypes.EAN13); try { // Error message will not been thrown in case of false, default value is also false and Get barcode image builder.ThrowExceptionWhenCodeTextIncorrect = true; Bitmap bitmap = builder.GenerateBarCodeImage(); } catch (Exception ex) { Console.WriteLine("Exception must be thrown, {0}", ex.Message); } // ExEnd:OptionalExceptionMessageWith1DBarCode }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes(); // Initialize a BarCodeBuilder class object and Set CodeText & Symbology Type BarCodeBuilder builder = new BarCodeBuilder("12345TEXT", EncodeTypes.QR); // Set encoding mode, Auto for Micro QR, error correction level builder.QREncodeMode = QREncodeMode.Auto; builder.QREncodeType = QREncodeType.Auto; builder.QRErrorLevel = QRErrorLevel.LevelL; // Get barcode image Bitmap and Save QR code Bitmap lBmp = builder.GenerateBarCodeImage(); lBmp.Save(dataDir + "EncodeMicroQRCode_out.bmp", ImageFormat.Bmp); }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes(); // initialize a BarCodeBuilder class object and Set its CodeText & Symbology Type BarCodeBuilder builder = new BarCodeBuilder("12345TEXT", EncodeTypes.QR); // Set encoding mode, ForceQR (default) for standard QR, ECI encoding type, error correction level builder.QREncodeMode = QREncodeMode.ECIEncoding; builder.QREncodeType = QREncodeType.ForceQR; builder.ECIEncoding = ECIEncodings.UTF8; builder.QRErrorLevel = QRErrorLevel.LevelL; // Get barcode image Bitmap & Save QR code Bitmap lBmp = builder.GenerateBarCodeImage(); lBmp.Save(dataDir + "EncodeQRCodEInECIMode_out.bmp", ImageFormat.Bmp); }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes(); // Initialize a BarCodeBuilder class object and Set CodeText & Symbology Type BarCodeBuilder builder = new BarCodeBuilder("12345TEXT", EncodeTypes.QR) { // Set ForceQR (default) for standard QR and Code text QREncodeMode = QREncodeMode.Auto, QREncodeType = QREncodeType.ForceQR, QRErrorLevel = QRErrorLevel.LevelL }; // Get barcode image Bitmap and Save QR code Bitmap lBmp = builder.GenerateBarCodeImage(); lBmp.Save(dataDir + "EncodeQA_out.bmp", ImageFormat.Bmp); }
public static void GS1DatamatrixBarcodeWithWrappingText() { //ExStart: GS1DatamatrixBarcodeWithWrappingText string CODICE = "(90)0843110730<<<<452287005001T8"; string displayedText = "(90)0843" + Environment.NewLine + "110730<<<<" + Environment.NewLine + "452287" + Environment.NewLine + "005001T8" + Environment.NewLine; using (BarCodeBuilder builder = new BarCodeBuilder(CODICE, EncodeTypes.GS1DataMatrix)) { builder.CodeLocation = CodeLocation.Right; builder.Display2DText = displayedText; Bitmap barcode = builder.GenerateBarCodeImage(); barcode.Save(dataDir + "Display2DText.png"); } //ExEnd: GS1DatamatrixBarcodeWithWrappingText }
public static void Run() { try { // ExStart:GenerateAndRecognizeUTF8Characters // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ManageBarCodes(); // Generate the barcode Bitmap imgBarcode = null; BarCodeBuilder objBarCodeBuilder = new BarCodeBuilder { EncodeType = EncodeTypes.MacroPdf417 }; // Set the codetext by converting it into unicode byte array byte[] byteArray = Encoding.Unicode.GetBytes("منحة"); objBarCodeBuilder.SetBinaryCodeText(byteArray); imgBarcode = objBarCodeBuilder.GenerateBarCodeImage(); imgBarcode.Save(dataDir + "GenerateAndRecognizeUTF8Characters_out.png"); // Recognize the above barcode BarCodeReader reader = new BarCodeReader(dataDir + "GenerateAndRecognizeUTF8Characters_out.png"); while (reader.Read()) { Encoding unicode = Encoding.Unicode; // Get the characters array from the bytes char[] unicodeChars = new char[unicode.GetCharCount(reader.GetCodeBytes(), 0, reader.GetCodeBytes().Length)]; unicode.GetChars(reader.GetCodeBytes(), 0, reader.GetCodeBytes().Length, unicodeChars, 0); // Build unicode string string strCodeText = new string(unicodeChars); Console.WriteLine(strCodeText); } reader.Close(); // ExEnd:GenerateAndRecognizeUTF8Characters } catch (Exception ex) { Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http://www.aspose.com/purchase/default.aspx."); } }
public static void Run() { //ExStart:EncodeMicroQRCode // The path to the documents directory. string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes(); // Initialize a BarCodeBuilder class object and Set CodeText & Symbology Type BarCodeBuilder builder = new BarCodeBuilder("12345TEXT", EncodeTypes.QR); // Set encoding mode, Auto for Micro QR, error correction level builder.QREncodeMode = QREncodeMode.Auto; builder.QREncodeType = QREncodeType.Auto; builder.QRErrorLevel = QRErrorLevel.LevelL; // Get barcode image Bitmap and Save QR code Bitmap lBmp = builder.GenerateBarCodeImage(); lBmp.Save(dataDir + "EncodeMicroQRCode_out.bmp", ImageFormat.Bmp); //ExEnd:EncodeMicroQRCode }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes(); // Create codetext QrExtCodetextBuilder lTextBuilder = new QrExtCodetextBuilder(); lTextBuilder.AddECICodetext(ECIEncodings.Win1251, "Will"); lTextBuilder.AddECICodetext(ECIEncodings.UTF8, "Right"); lTextBuilder.AddECICodetext(ECIEncodings.UTF16BE, "Power"); lTextBuilder.AddPlainCodetext(@"t\e\\st"); // Generate codetext string lCodetext = lTextBuilder.GetExtendedCodetext(); // Initialize a BarCodeBuilder class object BarCodeBuilder builder = new BarCodeBuilder(); // Set its Symbology builder.SymbologyType = Symbology.QR; // set encoding mode builder.QREncodeMode = QREncodeMode.ExtendedCodetext; // Set error correction level builder.QRErrorLevel = QRErrorLevel.LevelL; // Set code text builder.CodeText = lCodetext; // Set display text builder.Display2DText = "My Text"; // Get barcode image Bitmap Bitmap lBmp = builder.GenerateBarCodeImage(); // Save QR code lBmp.Save(dataDir + "MultiECIModeInExtendedMode_out.bmp", ImageFormat.Bmp); }
public static void Run() { //ExStart:EncodeQRCodEInECIMode // The path to the documents directory. string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes(); // initialize a BarCodeBuilder class object and Set its CodeText & Symbology Type BarCodeBuilder builder = new BarCodeBuilder("12345TEXT", EncodeTypes.QR); // Set encoding mode, ForceQR (default) for standard QR, ECI encoding type, error correction level builder.QREncodeMode = QREncodeMode.ECIEncoding; builder.QREncodeType = QREncodeType.ForceQR; builder.ECIEncoding = ECIEncodings.UTF8; builder.QRErrorLevel = QRErrorLevel.LevelL; // Get barcode image Bitmap & Save QR code Bitmap lBmp = builder.GenerateBarCodeImage(); lBmp.Save(dataDir + "EncodeQRCodEInECIMode_out.bmp", ImageFormat.Bmp); //ExEnd:EncodeQRCodEInECIMode }
public static void Run() { //ExStart:EncodeQRCode // The path to the documents directory. string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes(); // Initialize a BarCodeBuilder class object and Set CodeText & Symbology Type BarCodeBuilder builder = new BarCodeBuilder("12345TEXT", EncodeTypes.QR) { // Set ForceQR (default) for standard QR and Code text QREncodeMode = QREncodeMode.Auto, QREncodeType = QREncodeType.ForceQR, QRErrorLevel = QRErrorLevel.LevelL }; // Get barcode image Bitmap and Save QR code Bitmap lBmp = builder.GenerateBarCodeImage(); lBmp.Save(dataDir + "EncodeQA_out.bmp", ImageFormat.Bmp); //ExEnd:EncodeQRCode }
public static void Run() { try { // ExStart:GenerateAndRecognizeUTF8Characters // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ManageBarCodes(); // Generate the barcode Bitmap imgBarcode = null; BarCodeBuilder objBarCodeBuilder = new BarCodeBuilder {EncodeType = EncodeTypes.MacroPdf417}; // Set the codetext by converting it into unicode byte array byte[] byteArray = Encoding.Unicode.GetBytes("منحة"); objBarCodeBuilder.SetBinaryCodeText(byteArray); imgBarcode = objBarCodeBuilder.GenerateBarCodeImage(); imgBarcode.Save(dataDir + "GenerateAndRecognizeUTF8Characters_out.png"); // Recognize the above barcode BarCodeReader reader = new BarCodeReader(dataDir + "GenerateAndRecognizeUTF8Characters_out.png"); while (reader.Read()) { Encoding unicode = Encoding.Unicode; // Get the characters array from the bytes char[] unicodeChars = new char[unicode.GetCharCount(reader.GetCodeBytes(), 0, reader.GetCodeBytes().Length)]; unicode.GetChars(reader.GetCodeBytes(), 0, reader.GetCodeBytes().Length, unicodeChars, 0); // Build unicode string string strCodeText = new string(unicodeChars); Console.WriteLine(strCodeText); } reader.Close(); // ExEnd:GenerateAndRecognizeUTF8Characters } catch (Exception ex) { Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http://www.aspose.com/purchase/default.aspx."); } }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes(); // Create codetext QrExtCodetextBuilder lTextBuilder = new QrExtCodetextBuilder(); lTextBuilder.AddFNC1FirstPosition(); lTextBuilder.AddPlainCodetext("000%89%%0"); lTextBuilder.AddFNC1GroupSeparator(); lTextBuilder.AddPlainCodetext("12345<FNC1>"); // Generate codetext string lCodetext = lTextBuilder.GetExtendedCodetext(); // Instantiate barcode object BarCodeBuilder builder = new BarCodeBuilder(); // Set its Symbology builder.SymbologyType = Symbology.QR; // Set encoding mode builder.QREncodeMode = QREncodeMode.ExtendedCodetext; // Set error correction level builder.QRErrorLevel = QRErrorLevel.LevelL; // Set code text builder.CodeText = lCodetext; // Set display text builder.Display2DText = "My Text"; // Get barcode image Bitmap Bitmap lBmp = builder.GenerateBarCodeImage(); // Save QR code lBmp.Save(dataDir + "FNC1FirstPositionInExtendedMode_out.bmp", ImageFormat.Bmp); }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes(); // Create codetext QrExtCodetextBuilder lTextBuilder = new QrExtCodetextBuilder(); lTextBuilder.AddFNC1SecondPosition("12"); lTextBuilder.AddPlainCodetext("TRUE3456"); // Generate codetext string lCodetext = lTextBuilder.GetExtendedCodetext(); // Instantiate barcode object and Set its CodeText, encoding mode, error correction level, display text and Symbology BarCodeBuilder builder = new BarCodeBuilder(lCodetext, EncodeTypes.QR); builder.QREncodeMode = QREncodeMode.ExtendedCodetext; builder.QRErrorLevel = QRErrorLevel.LevelL; builder.Display2DText = "My Text"; // Get barcode image Bitmap and Save QR code Bitmap lBmp = builder.GenerateBarCodeImage(); lBmp.Save(dataDir + "FNC1SecondPositionInExtendedMode_out.bmp", ImageFormat.Bmp); }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes(); // Create codetext QrExtCodetextBuilder lTextBuilder = new QrExtCodetextBuilder(); lTextBuilder.AddECICodetext(ECIEncodings.Win1251, "Will"); lTextBuilder.AddECICodetext(ECIEncodings.UTF8, "Right"); lTextBuilder.AddECICodetext(ECIEncodings.UTF16BE, "Power"); lTextBuilder.AddPlainCodetext(@"t\e\\st"); // Generate codetext string lCodetext = lTextBuilder.GetExtendedCodetext(); // Initialize a BarCodeBuilder class object, Set CodeText, Symbology, Encoding mode, correction level and display text BarCodeBuilder builder = new BarCodeBuilder(lCodetext, EncodeTypes.QR); builder.QREncodeMode = QREncodeMode.ExtendedCodetext; builder.QRErrorLevel = QRErrorLevel.LevelL; builder.CodeText = lCodetext; builder.Display2DText = "My Text"; Bitmap lBmp = builder.GenerateBarCodeImage(); lBmp.Save(dataDir + "MultiECIModeInExtendedMode_out.bmp", ImageFormat.Bmp); }
/// <summary> /// Generates a barcode image. /// </summary> /// <param name="barcode">barcode number</param> /// <returns>barcode image</returns> public static Bitmap GenerateBarcodeImage(string barcode) { BarCodeBuilder builder = new BarCodeBuilder(barcode, Symbology.Code128); return(builder.GenerateBarCodeImage()); }