Take the following steps to create and run a program that uses the LEADTOOLS Barcode write activity to recognize barcodes in an image:
- Start Visual Studio .NET.
- Choose File->New->Project... from the menu.
- In the New Project dialog box, choose either "Visual C#" or "Visual Basic" then "Workflow" in the Projects Type List, and choose "Sequential Workflow Console Application" in the Templates List.
- Type the project name as "WfBarcodeWriteTest" in the Project Name field, and then choose OK. If desired, type a new location for your project or select a directory using the Browse button, and then choose OK.
- In the "Solution Explorer" window, right-click on the "References" folder, and select "Add Reference..." from the context menu. In the "Add Reference..." dialog box, select the ".NET" tab, browse to the "C:\LEADTOOLS 17.5\Bin\DotNet\Win32 " folder, and select the following DLLs:
- Leadtools.Workflow.Raster.dll
- Leadtools.Workflow.Barcode.dll
Click Select and then click OK to add the above DLLs to the application.
- To add the LEADTOOLS activities to your toolbox, right-click the toolbox and select "Choose Items". In the "Choose Toolbox Items" dialog, go the "Activities" tab, and browse for and select the same DLLs in step (5).
- Double-click your project's workflow to open it for editing, then select the UnlockSupportActivity, LoadImageActivity, BarcodeWriteActivity and SaveImageActivity activities from the toolbox and place them on the workflow in that order. Add a handler to the workflow's Initialized event and add the below code to it:
[C#]
unlockSupportActivity1.UnlockedFeatures.Add(Leadtools.Workflow.Raster.RasterSupportType.Barcodes1D, "Replace with your own key here");
Leadtools.Workflow.Barcode.BarcodeData data = new Leadtools.Workflow.Barcode.BarcodeData();
data.Unit = Leadtools.Workflow.Barcode.BarcodeUnit.ScanlinesPerPixels;
data.SearchType = Leadtools.Workflow.Barcode.BarcodeSearchTypeFlags.Barcode1dCode3Of9;
data.Data = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1};
data.Location = Rectangle.Empty;
barcodeWriteActivity1.BarColor = Color.Black;
barcodeWriteActivity1.SpaceColor = Color.White;
barcodeWriteActivity1.MajorType = Leadtools.Workflow.Barcode.BarcodeMajorTypeFlags.Barcodes1d;
barcodeWriteActivity1.BarcodeData = data;
[Visual Basic]
unlockSupportActivity1.UnlockedFeatures.Add(Leadtools.Workflow.Raster.RasterSupportType.Barcodes1D, "Replace with your own key here")
Dim data As Leadtools.Workflow.Barcode.BarcodeData = New Leadtools.Workflow.Barcode.BarcodeData()
data.Unit = Leadtools.Workflow.Barcode.BarcodeUnit.ScanlinesPerPixels
data.SearchType = Leadtools.Workflow.Barcode.BarcodeSearchTypeFlags.Barcode1dCode3Of9
data.Data = New Byte() {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1}
data.Location = Rectangle.Empty
barcodeWriteActivity1.BarColor = Color.Black
barcodeWriteActivity1.SpaceColor = Color.White
barcodeWriteActivity1.MajorType = Leadtools.Workflow.Barcode.BarcodeMajorTypeFlags.Barcodes1d
barcodeWriteActivity1.BarcodeData = data
- Set the Url property of the LoadImageActivity to "\LEADTOOLS 17.5\Images\Barcode1.TIF".
- Set the Format property of the SaveImageActivity to Ccitt and the TargetFile property to "C:\barcode.tif".
- Bind the Image property of the BarcodeWriteActivity to the Image property of the LoadImageActivity.
- Bind the Image property of the SaveImageActivity to the Image property of the BarcodeWriteActivity.
- Set the output folder of the project .exe to where LEADTOOLS .Net DLLs are installed. For example: <LEADTOOLS_INSTALLDIR>\Bin\Dotnet\Win32
- Build, and Run the program to test it.