←Select platform

UseXModule Property

Summary
Gets or sets a value that indicates whether to use the XModule when writing barcodes of this type.
Syntax
C#
Objective-C
C++/CLI
Python
public bool UseXModule { get; set; } 
@property (nonatomic, assign) BOOL useXModule; 
public: 
property bool UseXModule { 
   bool get(); 
   void set (    bool ); 
} 
UseXModule # get and set (PharmaCodeBarcodeWriteOptions) 

Property Value

true to use XModule when writing barcodes of this type. Otherwise, false. The default value is false.

Remarks

When the value of UseXModule is set to false, then the smallest module size is calculated from the size of the barcode data (BarcodeData.Bounds).

When the value of UseXModule is set to true, then the smallest module size is set in XModule and the barcode data size may be used as a "clipping" boundary.

For more information, refer to Writing Barcodes - Bounds and XModule.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Barcode; 
using Leadtools.ImageProcessing; 
 
 
public void BarcodeWriteOptions_Example() 
{ 
   // This example uses derived classes from the abstract class BarcodeWriteOptions to set the barcode write options. 
   // For example: OneDBarcodeWriteOptions, GS1DatabarStackedBarcodeWriteOptions, 
   // PatchCodeBarcodeWriteOptions, PostNetPlanetBarcodeWriteOptions are derived 
   // from the abstract class BarcodeWriteOptions 
 
   // Create a directory to store the images we will create 
   string outDir = Path.Combine(LEAD_VARS.ImagesDir, "MyBarcodes"); 
   if (Directory.Exists(outDir)) 
   { 
      Directory.Delete(outDir, true); 
   } 
   Directory.CreateDirectory(outDir); 
 
   int resolution = 300; 
 
   // Create a Barcode engine 
   BarcodeEngine engine = new BarcodeEngine(); 
 
   // Get the Barcode writer 
   BarcodeWriter writer = engine.Writer; 
 
   // All 1D options have the UseXModule set to false by default, we need to set it to true 
   // so we can calculate the default size. We will change the default options so we can 
   // pass null to CalculateBarcodeDataBounds and WriteBarcode below 
 
   // For all Standard 1D.  
   OneDBarcodeWriteOptions oneDWriteOptions = writer.GetDefaultOptions(BarcodeSymbology.UPCA) as OneDBarcodeWriteOptions; 
   oneDWriteOptions.UseXModule = true; 
 
   // All GS1 Databar Stacked 
   GS1DatabarStackedBarcodeWriteOptions gs1DatabarStackedWriteOptions = writer.GetDefaultOptions(BarcodeSymbology.GS1DatabarStacked) as GS1DatabarStackedBarcodeWriteOptions; 
   gs1DatabarStackedWriteOptions.UseXModule = true; 
 
   // Patch Code 
   PatchCodeBarcodeWriteOptions patchCodeWriteOptions = writer.GetDefaultOptions(BarcodeSymbology.PatchCode) as PatchCodeBarcodeWriteOptions; 
   patchCodeWriteOptions.UseXModule = true; 
 
   // All PostNet/Planet 
   PostNetPlanetBarcodeWriteOptions postNetPlanetWriteOptions = writer.GetDefaultOptions(BarcodeSymbology.PostNet) as PostNetPlanetBarcodeWriteOptions; 
   postNetPlanetWriteOptions.UseXModule = true; 
 
   // Pharma code 
   PharmaCodeBarcodeWriteOptions pharmaCodeBarcodeWriteOptions = writer.GetDefaultOptions(BarcodeSymbology.PharmaCode) as PharmaCodeBarcodeWriteOptions; 
   pharmaCodeBarcodeWriteOptions.UseXModule = true; 
   pharmaCodeBarcodeWriteOptions.XModule = 30; 
 
   // We will use this object to save files 
   using (RasterCodecs codecs = new RasterCodecs()) 
   { 
      // Get all the available write symbologies 
      BarcodeSymbology[] symbologies = writer.GetAvailableSymbologies(); 
      foreach (BarcodeSymbology symbology in symbologies) 
      { 
         Console.WriteLine("Processing {0}", symbology); 
 
         // Create the default data for this symbology 
         BarcodeData data = BarcodeData.CreateDefaultBarcodeData(symbology); 
 
         // Calculate its size with default options 
         writer.CalculateBarcodeDataBounds(LeadRect.Empty, resolution, resolution, data, null); 
 
         // Create an image to write the data to 
         LeadRect pixels = data.Bounds; 
         using (RasterImage image = RasterImage.Create(pixels.Width, pixels.Height, 1, resolution, RasterColor.FromKnownColor(RasterKnownColor.White))) 
         { 
            // Write the barcode with default options 
            writer.WriteBarcode(image, data, null); 
 
            // Save it 
            string outFileName = Path.Combine(outDir, symbology + ".tif"); 
            codecs.Save(image, outFileName, RasterImageFormat.Tif, 1); 
         } 
      } 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.5.9
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Barcode Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.