static void Main(string[] args) { // Create new barcode Barcode barcode = new Barcode(); // Set symbology barcode.Symbology = SymbologyType.MacroPDF417; // we will encode value 123456789 // will break into 3 segments, each segment includes 3 symbols Macro417SegmentHelper macro417SegmentHelper = new Macro417SegmentHelper(); macro417SegmentHelper.AddValue("123", "456", "789"); foreach (var itmSegment in macro417SegmentHelper.GetAllSegments()) { // create the first segment barcode so set SegmentIndex = 1 barcode.Options.PDF417SegmentIndex = itmSegment.SegmentIndex; // Set value barcode.Value = itmSegment.SegmentValue; // set that this is not the last segment yet barcode.Options.PDF417LastSegment = itmSegment.IsLastSegment; // Save barcode to image barcode.SaveImage($"MacroPDFBarcode-part{itmSegment.SegmentIndex}.png"); // Show image in default image viewer Process.Start($"MacroPDFBarcode-part{itmSegment.SegmentIndex}.png"); } }
static void Main(string[] args) { // Load text file string textInput = System.IO.File.ReadAllText("InputData.txt"); // Split text into chunks var lstChunks = textInput.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); // Create new barcode using (Barcode barcode = new Barcode("demo", "demo")) { // Keep generated barcode images in the list List <Image> images = new List <Image>(); // Select Macro PDF417 barcode type barcode.Symbology = SymbologyType.MacroPDF417; Macro417SegmentHelper macro417SegmentHelper = new Macro417SegmentHelper(); macro417SegmentHelper.AddValue(lstChunks); // Set FileID. // FileID is a number from 0 to 899. It must be same for all barcodes in the set. barcode.Options.PDF417FileID = 123; int ctr = 0; var resImgName = ""; foreach (var itmSegment in macro417SegmentHelper.GetAllSegments()) { // create the first segment barcode so set SegmentIndex = 1 barcode.Options.PDF417SegmentIndex = itmSegment.SegmentIndex; // Set value barcode.Value = itmSegment.SegmentValue; // set that this is not the last segment yet barcode.Options.PDF417LastSegment = itmSegment.IsLastSegment; // Save barcode to image resImgName = $"img{++ctr}.png"; barcode.SaveImage(resImgName, imageFormat: System.Drawing.Imaging.ImageFormat.Png); Console.WriteLine("'{0}' generated!", resImgName); } } Console.ReadLine(); }