public static void Run() { // ExStart:ManageXYDimension // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ManageBarCodes(); string dstCode128 = dataDir + "code128-YDimensionChanged_out.jpg"; // Instantiate barcode object and set CodeText & Barcode Symbology BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128, "1234567"); // Save the image to your system and set its image format to Jpeg generator.Save(dstCode128, BarCodeImageFormat.Jpeg); // Set the X-Dimension for the bars of the barcode generator.Parameters.Barcode.XDimension.Millimeters = 0.5f; // Save the image to your system and set its image format to Jpeg generator.Save(dstCode128, BarCodeImageFormat.Jpeg); // Instantiate barcode object and set differnt barcode properties using (BarcodeGenerator generator1 = new BarcodeGenerator(EncodeTypes.Pdf417, "1234567")) { generator1.Parameters.Barcode.BarCodeHeight.Millimeters = 4; // Save the image to your system and set its image format to Jpeg generator1.Save(dataDir + "pdf417-YDimensionChanged_out.jpg", BarCodeImageFormat.Jpeg); } // ExEnd:ManageXYDimension }
public static void Run() { // ExStart:WideNarrowRatio // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ManageBarCodes(); // Instantiate linear barcode object BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code39Standard, "1234567"); // Set the wide to narrow ratio for the barcode generator.Parameters.Barcode.WideNarrowRatio = 3.0f; // Save the image to your system and set its image format to Jpeg generator.Save(dataDir + "barcode_ratio_3_out.jpg", BarCodeImageFormat.Jpeg); // Set the wide to narrow ratio for the barcode generator.Parameters.Barcode.WideNarrowRatio = 5.0f; // Save the image to your system and set its image format to Jpeg generator.Save(dataDir + "barcode_ratio_5_out.jpg", BarCodeImageFormat.Jpeg); // Set the wide to narrow ratio for the barcode generator.Parameters.Barcode.WideNarrowRatio = 7.0f; // Save the image to your system and set its image format to Jpeg generator.Save(dataDir + "barcode_ratio_7_out.jpg", BarCodeImageFormat.Jpeg); // Set the wide to narrow ratio for the barcode generator.Parameters.Barcode.WideNarrowRatio = 9.0f; // Save the image to your system and set its image format to Jpeg generator.Save(dataDir + "code39-wide-narrow-ratio_out.jpg", BarCodeImageFormat.Jpeg); // ExEnd:WideNarrowRatio }
public static void UnitBasedBarcodeGenerateion() { //ExStart: UnitBasedBarcodeGenerateion using (BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.QR, "Aspose.BarCode sample")) { generator.Parameters.Barcode.AutoSizeMode = AutoSizeMode.Nearest; generator.Parameters.Barcode.BarCodeWidth.Millimeters = 20; generator.Parameters.Barcode.BarCodeHeight.Millimeters = 20; generator.Save(dataDir + "for_display_out.png"); generator.Parameters.Resolution = 300; generator.Save(dataDir + "for_printer_out.png"); } //ExEnd: UnitBasedBarcodeGenerateion Console.WriteLine(Environment.NewLine + "Barcode saved at " + dataDir + "for_printer_out.png"); }
public FileResult Index(string editor1, string codeText, string barcodeType) { // generate a barcode string barcodeImagePath = Path.Combine("wwwroot/barcodes/", Guid.NewGuid() + ".png"); SymbologyEncodeType type = GetBarcodeSymbology(barcodeType); BarcodeGenerator generator = new BarcodeGenerator(type, codeText); generator.Parameters.BackColor = System.Drawing.Color.Transparent; // set resolution of the barcode image generator.Parameters.Resolution = 200; // generate barcode generator.Save(barcodeImagePath, BarCodeImageFormat.Png); // create a unique file name for PDF string fileName = Guid.NewGuid() + ".pdf"; // convert HTML text to stream byte[] byteArray = Encoding.UTF8.GetBytes(editor1); // generate PDF from the HTML MemoryStream stream = new MemoryStream(byteArray); HtmlLoadOptions options = new HtmlLoadOptions(); Document pdfDocument = new Document(stream, options); // add barcode image to the generated PDF pdfDocument = InsertImage(pdfDocument, barcodeImagePath); // create memory stream for the PDF file Stream outputStream = new MemoryStream(); // save PDF to output stream pdfDocument.Save(outputStream); // return generated PDF file return(File(outputStream, System.Net.Mime.MediaTypeNames.Application.Pdf, fileName)); }
public static void Run() { //ExStart:UseEncodeModeDatamatrixbarcode // The path to the documents directory. string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes(); string gtin = "898978777776665655"; string uid = "121212121212121212"; string batch = "GH768"; string expDate = "150923"; string textToEncode = gtin + uid + batch + expDate; // Or "(01)"+ gtin + "(..)"+ uid + ... string textToDisplay = "GTIN:" + gtin + "\nUID:" + uid + "\nBatch:" + batch + "\nExp.Date:" + expDate; // Instantiate barcode object and set N order to avoid including all the names into the codetext, the property called "Display2DText" should be used. BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.DataMatrix, "textToEncode"); generator.Parameters.Barcode.CodeTextParameters.TwoDDisplayText = textToDisplay; generator.Parameters.Barcode.CodeTextParameters.Location = CodeLocation.Below; // Builder.CodeTextSpace = 0; // Not recommended small space // Save the Barcode image generator.Save(dataDir + "codetextRightDisplay_out.png", BarCodeImageFormat.Png); //ExEnd:UseEncodeModeDatamatrixbarcode Console.WriteLine(Environment.NewLine + "Barcode saved at " + dataDir + "codetextRightDisplay_out.png"); }
public static void Run() { // ExStart:AddingBarcodeImageToExcelWorksheet // For complete examples and data files, please go to https://github.com/aspose-barcode/Aspose.BarCode-for-.NET // The path to the documents directory. string dataDir = RunExamples.GetDataDir_TechnicalArticles(); // Instantiate linear barcode object, Set the Code text and symbology type for the barcode BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128, "1234567"); // Creating memory stream and Saving barcode image to memory stream System.IO.Stream ms = new System.IO.MemoryStream(); generator.Save(ms, BarCodeImageFormat.Bmp); // Instantiate Excel class that represents an excel file Workbook excel1 = new Workbook(); // Add the barcode image into the pictures collection of the first worksheet of the excel file in the form of a MemoryStream, ms with upper left row=5 and // Upper left column=5 and Save the excel file excel1.Worksheets[0].Pictures.Add(5, 5, ms); excel1.Save(dataDir + "MyFile_out.xls"); // ExEnd:AddingBarcodeImageToExcelWorksheet Console.WriteLine(Environment.NewLine + "Adding Barcode Image To Excel Worksheet Finished."); }
public static void Run() { // ExStart:SetITF14SpecifyBorderType // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ManageBarCodesImages(); // Instantiate barcode object and set CodeText & Barcode Symbology BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.ITF14, "00850006000227"); // Set ITF14 Barcode Border Type generator.Parameters.Barcode.ITF.ItfBorderType = ITF14BorderType.FrameOut; // Set Font generator.Parameters.Barcode.CodeTextParameters.Font.FamilyName = "OCR B Std"; generator.Parameters.Barcode.CodeTextParameters.Font.Size.Point = 8; // Set xDimension generator.Parameters.Barcode.XDimension.Millimeters = 0.495f; // Set Bars Height generator.Parameters.Barcode.BarHeight.Millimeters = 12.7f; // Specify space between characters generator.Parameters.Barcode.CodeTextParameters.Space.Millimeters = 0.5f; // Define resolution generator.Parameters.Resolution = 1200.0f; generator.Save(dataDir + "ITF14_Border_Type_Frame_out.png", BarCodeImageFormat.Png); // ExEnd:SetITF14SpecifyBorderType }
public static void Run() { // ExStart:ManageCaption // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ManageBarCodes(); // Instantiate barcode object and set CodeText & Barcode Symbology BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128, "1234567"); // Set caption above its text and text alignment & also make it visible generator.Parameters.CaptionAbove.Visible = true; generator.Parameters.CaptionAbove.Text = "Aspose"; generator.Parameters.CaptionAbove.Alignment = TextAlignment.Center; generator.Parameters.CaptionAbove.TextColor = Color.Red; generator.Parameters.CaptionAbove.Font.FamilyName = "Pristina"; generator.Parameters.CaptionAbove.Font.Size.Point = 14; //space between the barcode and the caption //generator.Parameters.CaptionAbove.Space.Millimeters = 5; // Assign caption object to be displayed above the barcode generator.Parameters.CaptionBelow.Visible = true; generator.Parameters.CaptionBelow.Text = "Aspose Caption below"; generator.Parameters.CaptionBelow.Alignment = TextAlignment.Center; generator.Parameters.CaptionBelow.TextColor = Color.OrangeRed; generator.Parameters.CaptionBelow.Font.Size.Point = 14; generator.Parameters.CaptionBelow.Font.FamilyName = "Pristina"; //space between the barcode and the caption //generator.CaptionBelow.Space.Millimeters = 5; // Save the image to your system and set its image format to Jpeg generator.Save(dataDir + "ManageCaption_out.jpg", BarCodeImageFormat.Jpeg); Console.WriteLine(Environment.NewLine + "Barcode saved at " + dataDir); // ExEnd:ManageCaption }
public static void Run() { //ExStart:DetectUnicodeEncoding // The path to the documents directory. string dataDir = RunExamples.GetDataDir_CreateAndManage2DBarCodes(); try { MemoryStream memoryStream = new MemoryStream(); // Instantiate barcode object, Set CodeText, Barcode Symbology and Text Encoding using (BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.QR, "Слово")) { generator.Parameters.Barcode.QR.CodeTextEncoding = Encoding.UTF8; generator.Save(dataDir + "" + memoryStream + "_out.png", BarCodeImageFormat.Png); } string fileName = dataDir + "" + memoryStream + "_out.png"; using (BarCodeReader reader = new BarCodeReader(fileName, DecodeType.QR)) { var detectEnc = reader.DetectEncoding; foreach (BarCodeResult result in reader.ReadBarCodes()) { Console.WriteLine(result.CodeText); //"Слово" } } } catch (Exception) {} //ExEnd:DetectUnicodeEncoding }
public static void Run() { // ExStart:SetFontandColorSetting // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ManageBarCodesImages(); // Instantiate barcode object BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128); generator.Parameters.CaptionAbove.Visible = true; generator.Parameters.CaptionAbove.Text = "Aspose"; generator.Parameters.CaptionAbove.Alignment = TextAlignment.Center; generator.Parameters.CaptionAbove.TextColor = Color.Red; generator.Parameters.CaptionAbove.Font.FamilyName = "Pristina"; generator.Parameters.CaptionAbove.Font.Size.Point = 14; generator.Parameters.CaptionBelow.Alignment = TextAlignment.Center; generator.Parameters.CaptionBelow.Text = "Aspose.Demo"; generator.Parameters.CaptionBelow.Visible = true; generator.Parameters.CaptionBelow.Font.FamilyName = "Pristina"; generator.Parameters.CaptionBelow.Font.Size.Point = 14; generator.Parameters.CaptionBelow.TextColor = Color.OrangeRed; // Save the image to your system and set its image format to Jpeg generator.Save(dataDir + "SetFontandColorSetting_out.jpeg", BarCodeImageFormat.Jpeg); // ExEnd:SetFontandColorSetting }
public ResultData Run(StepStartData data) { // You will have to run another step before this one or provide a license for the Aspose library. // Step to run before this one: RecognizeBarcodesFromWordDoc. string barCodeText = data[INPUT_BAR_CODE_TEXT] as string; if (string.IsNullOrEmpty(barCodeText)) { throw new BusinessRuleException("You cannot generate a bar code without any barcode text."); } BarcodeGenerator generator = new BarcodeGenerator(GetEncodeTypeFromName(BarcodeEncodingType), barCodeText); generator.Parameters.Barcode.XDimension.Millimeters = 1f; FileData fdResult = null; using (MemoryStream ms = new MemoryStream()) { // Save the image to your system and set its image format to Jpeg generator.Save(ms, BarCodeImageFormat.Jpeg); fdResult = new FileData("BarCode.jpg", ms.ToArray()); } return(new ResultData(PATH_DONE, new DataPair[] { new DataPair(RESULT_DATA_FILE, fdResult) })); }
public static void ImplementUpcaGs1DatabarCouponForNewBarcode() { //ExStart: ImplementUpcaGs1DatabarCouponForNewBarcode using (BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.UpcaGs1DatabarCoupon)) { generator.Save(dataDir + "UpcaGs1DatabarCoupon.png"); } //ExEnd: ImplementUpcaGs1DatabarCouponForNewBarcode Console.WriteLine(Environment.NewLine + "Barcode saved at " + dataDir + "UpcaGs1DatabarCoupon.png"); }
public static void ImportBarcodeFromXML(string dataDir) { // ExStart:ImportBarcodeFromXML string xmlFile = dataDir + "barcode.xml"; // Instantiate barcode object and set CodeText & Barcode Symbology BarcodeGenerator generator = BarcodeGenerator.ImportFromXml(xmlFile); generator.Save(dataDir + "barcode_xml_out.jpg", BarCodeImageFormat.Jpeg); // ExEnd:ImportBarcodeFromXML Console.WriteLine(Environment.NewLine + "Imported barcode saved at " + dataDir); }
public static void Run() { // ExStart:CreatePDF417Barcode // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ManageBarCodes(); // Instantiate BarcodeGenerator object Set the Code text & SymbologyType for the barcode BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Pdf417, "1234567890"); generator.Save(dataDir + "pdf417-barcode_out.jpg", BarCodeImageFormat.Jpeg); // ExEnd:CreatePDF417Barcode }
public static void Run() { // ExStart:SwissPostParcelSymbology // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ManageBarCodes(); // Generate the barcode and Save barcode on local BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.SwissPostParcel, "0610"); generator.Save(dataDir + "SwissPostParcelSymbology_out.png"); // ExEnd:SwissPostParcelSymbology }
public static void Run() { // ExStart:SwissPostParcelBarcodeWithInternationalMailType // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ManageBarCodes(); // Generate the barcode and Save barcode on local BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.SwissPostParcel, "RA121212122CH"); generator.Save(dataDir + "SwissPostParcelBarcodeWithInternationalMailType_out.png"); // ExEnd:SwissPostParcelBarcodeWithInternationalMailType }
public static void Run() { // ExStart:CreateQRbarcode // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ManageBarCodes(); // Instantiate barcode object and set CodeText & Barcode Symbology BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.QR, "1234567890"); generator.Save(dataDir + "CreateQRbarcode_out.bmp", BarCodeImageFormat.Bmp); // ExEnd:CreateQRbarcode }
public static void Run() { // ExStart:CreateCouponExtendedBarcode // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ManageBarCodes(); // Instantiate barcode object and set CodeText & Barcode Symbology BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.UpcaGs1Code128Coupon, "514141100906(8102)03"); generator.Save(dataDir + "UpcaGs1Code128Coupon_out.png"); // ExEnd:CreateCouponExtendedBarcode }
public static void GenarateBarcodeWithRotationAndDpi() { //ExStart: GenarateBarcodeWithRotationAndDpi using (BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128)) { generator.Parameters.Resolution = 144; generator.Parameters.RotationAngle = 90; generator.Save(dataDir + "rotated_dpi144.png"); } //ExEnd: GenarateBarcodeWithRotationAndDpi Console.WriteLine(Environment.NewLine + "Barcode saved at " + dataDir + "rotated_dpi144.png"); }
public static void Run() { // ExStart:SwissPostParcelBarcodeWithAdditionalServiceType // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ManageBarCodes(); // Generate the barcode, Set codeText, SymbologyType and Save barcode on local disk BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.SwissPostParcel, "989967121212121212"); generator.Save(dataDir + "SwissPostParcelBarcodeWithAdditionalServiceType_out.Png"); // ExEnd:SwissPostParcelBarcodeWithAdditionalServiceType }
public static void GroupingPropertiesByBarcodeType() { //ExStart: GroupingPropertiesByBarcodeType using (BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.QR)) { generator.Parameters.Barcode.QR.QrVersion = QRVersion.Version18; generator.Parameters.Barcode.QR.QrErrorLevel = QRErrorLevel.LevelM; generator.Save(dataDir + "qr_out.png"); } //ExEnd: GroupingPropertiesByBarcodeType Console.WriteLine(Environment.NewLine + "Barcode saved at " + dataDir + "qr_out.png"); }
public static void Run() { // ExStart:CreateCode128Barcode // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ManageBarCodes(); // Instantiate barcode object and set CodeText & Barcode Symbology BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128, "1234"); generator.Save(dataDir + "Code128-customized_out.png"); // ExEnd:CreateCode128Barcode }
public static void Run() { // ExStart:SpecifySymbologies // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ManageBarCodes(); // Instantiate barcode object BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128, "1234567"); generator.Save(dataDir + "barcode-SpecifySymbologies_out.jpg", BarCodeImageFormat.Jpeg); // ExEnd:SpecifySymbologies }
public static void Run() { // ExStart:SetQREncodeMode // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ManageBarCodes(); // Create instance of BarcodeGenerator , specify codetext symbology and encode mode BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.QR, "test123"); generator.Parameters.Barcode.QR.QrEncodeMode = QREncodeMode.Auto; generator.Save(dataDir + "QR-Encode-mode_out.jpg"); // ExEnd:SetQREncodeMode }
public static void Run() { // ExStart:AddSpaceInBarCodeAndText // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ManageBarCodesImages(); // Instantiate barcode object and set Increase the space between code text and barcode to 1 point BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code93Standard); generator.Parameters.Barcode.CodeTextParameters.Space.Millimeters = 1.0f; generator.Save(dataDir + "AddSpaceInBarCodeAndText_out.bmp", BarCodeImageFormat.Bmp); // ExEnd:AddSpaceInBarCodeAndText }
public static void Run() { // ExStart:GeneratingGS1ForCodablock // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ManageBarCodes(); // Create instance of BarcodeGenerator class. BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.GS1CodablockF, "(01)03412345678900(17)010200"); // Save the image to disk in PNG format generator.Save("GS1CodablockF_out.png", BarCodeImageFormat.Png); // ExEnd:GeneratingGS1ForCodablock }
public static void GenerateCode16KBarCode() { //ExStart: GenerateCode16KBarCode using (BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code16K)) { generator.Parameters.Barcode.AutoSizeMode = AutoSizeMode.Nearest; generator.Parameters.Barcode.BarCodeWidth.Pixels = 100; generator.Parameters.Barcode.CodeTextParameters.Location = CodeLocation.None; generator.Save(dataDir + "Code16K_Nearest.png"); } //ExEnd: GenerateCode16KBarCode Console.WriteLine(Environment.NewLine + "Barcode saved at " + dataDir + "Code16K_Nearest.png"); }
public static void Run() { // ExStart:SpecifySymbology // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ManageBarCodes(); // Instantiate barcode object and set differnt barcode properties BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128, "1234567"); // Save the image to your system and set its image format to Jpeg generator.Save(dataDir + "barcode-symbiology_out.jpg", BarCodeImageFormat.Jpeg); // ExEnd:SpecifySymbology }
public static void Run() { // ExStart:SetForeColorText // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ManageBarCodesImages(); // Instantiate barcode object and set differnt barcode properties BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128, "1234567"); generator.Parameters.Barcode.CodeTextParameters.Color = Color.Red; generator.Save(dataDir + "barcode-SetForeColorText_out.jpg", BarCodeImageFormat.Jpeg); // ExEnd:SetForeColorText }
public static void Run() { // ExStart:SaveBarcodeImagesToDifferentFormats // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ManageBarCodesImages(); // Instantiate barcode object and set CodeText & Barcode Symbology BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128); generator.CodeText = "1234567"; generator.Save(dataDir + "barcode-image-format_out.jpeg", BarCodeImageFormat.Jpeg); // ExEnd:SaveBarcodeImagesToDifferentFormats }