public static void Run() { try { // ExStart:CreateAndSetSizeForImageWithBarcode // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ManageBarCodes(); // Generate the barcode and set code text, symbology type BarCodeBuilder builder = new BarCodeBuilder("One thing 2 thing", EncodeTypes.Pdf417); // Set the code text location, graphics unit and margins builder.CodeLocation = CodeLocation.None; builder.GraphicsUnit = GraphicsUnit.Pixel; builder.Margins.Set(0); // Get Bitmap with exact barcode only Bitmap bmp = builder.GetOnlyBarCodeImage(); // Allows to set size for whole picture with barcode inside and Save image on local disk Bitmap bitmap = builder.GetCustomSizeBarCodeImage(new Size(bmp.Width * 5, bmp.Height * 5), false); bitmap.Save(dataDir + "CreateAndSetSizeForImageWithBarcode_out.Png"); // ExEnd:CreateAndSetSizeForImageWithBarcode } 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() { try { // ExStart:CreateImageWithExactBarcodeOnly // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ManageBarCodes(); // Generate the barcode and set code text, symbology type BarCodeBuilder builder = new BarCodeBuilder("123456", EncodeTypes.Code128); // Get bitmap with exact barcode only and Save image on local disk Bitmap bmp = builder.GetOnlyBarCodeImage(); bmp.Save(dataDir + "CreateImageWithExactBarcodeOnly_out.png", ImageFormat.Png); // ExEnd:CreateImageWithExactBarcodeOnly } 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."); } }