←Select platform

PharmaCodeBarcodeWriteOptions Class

Summary
Contains the extra options to use when writing PharmaCode barcodes.
Syntax
C#
Objective-C
C++/CLI
Python
[SerializableAttribute()] 
public class PharmaCodeBarcodeWriteOptions : BarcodeWriteOptions 
@interface LTPharmaCodeBarcodeWriteOptions : LTBarcodeWriteOptions 
[TypeConverterAttribute()] 
[SerializableAttribute()] 
public ref class PharmaCodeBarcodeWriteOptions : public BarcodeWriteOptions, System.ICloneable   
class PharmaCodeBarcodeWriteOptions(BarcodeWriteOptions): 
Remarks

The PharmaCodeBarcodeWriteOptions class is used to control the options when writing PharmaCode barcodes using LEADTOOLS. Set the options in two ways:

The BarcodeWriter class contains default options for each barcode symbology (or group of common symbologies). These options can be retrieved using the BarcodeWriter.GetDefaultOptions method, passing BarcodeSymbology.PharmaCode.

Then change the members of the returned PharmaCodeBarcodeWriteOptions by casting it from BarcodeWriteOptions to PharmaCodeBarcodeWriteOptions.

You can also create an instance of the PharmaCodeBarcodeWriteOptions class and use it directly in the BarcodeWriter.WriteBarcode method which accepts the options as an input parameter.

The base BarcodeWriteOptions contains the following members and features:

Member Description
BarcodeWriteOptions.ForeColor

Controls the barcode foreground color (color of the bars or symbols) to use when writing a barcode to an image.

BarcodeWriteOptions.BackColor

Controls the barcode background color (color of the spaces) to use when writing a barcode to an image.

BarcodeWriteOptions.Load and BarcodeWriteOptions.Save

Can be used to save or load the options to/from an XML file or stream.

BarcodeWriteOptions.GetSupportedSymbologies

This class overrides the base class method to return an array containing the following symbologies: BarcodeSymbology.PharmaCode

In addition to the features and members, the PharmaCodeBarcodeWriteOptions contains these PharmaCode barcodes specific features:

Member Description
UseXModule

Uses the XModule when writing barcodes of this type

XModule

The size of the smallest module when writing a PharmaCode barcode

Example
C#
Java
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:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.Console; 
import java.io.File; 
import java.io.IOException; 
import java.nio.file.Path; 
import java.time.LocalDateTime; 
 
import org.apache.lucene.store.Directory; 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.barcode.*; 
import leadtools.codecs.*; 
 
 
public void barcodeWriteOptionsExample() { 
   // Create a directory to store the images we will create 
   String LEAD_VARS_ImagesDir = "C:\\LEADTOOLS23\\Resources\\Images"; 
   String outDir = combine(LEAD_VARS_ImagesDir, "MyBarcodes"); 
   File dir = new File(outDir); 
   if (dir.exists()) { 
      dir.delete(); 
   } 
   dir.mkdirs(); 
 
   int resolution = 300; 
 
   // Create a Barcode engine 
   BarcodeEngine engine = new BarcodeEngine(); 
 
   // Get the Barcode writer 
   BarcodeWriter writer = engine.getWriter(); 
 
   // 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 = (OneDBarcodeWriteOptions) writer 
         .getDefaultOptions(BarcodeSymbology.UPC_A); 
   oneDWriteOptions.setUseXModule(true); 
   assertTrue(oneDWriteOptions.getUseXModule() == true); 
 
   // All GS1 Databar Stacked 
   GS1DatabarStackedBarcodeWriteOptions gs1DatabarStackedWriteOptions = (GS1DatabarStackedBarcodeWriteOptions) writer 
         .getDefaultOptions(BarcodeSymbology.GS1_DATA_BAR_STACKED); 
   gs1DatabarStackedWriteOptions.setUseXModule(true); 
   assertTrue(gs1DatabarStackedWriteOptions.getUseXModule() == true); 
 
   // Patch Code 
   PatchCodeBarcodeWriteOptions patchCodeWriteOptions = (PatchCodeBarcodeWriteOptions) writer 
         .getDefaultOptions(BarcodeSymbology.PATCH_CODE); 
   patchCodeWriteOptions.setUseXModule(true); 
   assertTrue(patchCodeWriteOptions.getUseXModule() == true); 
 
   // All PostNet/Planet 
   PostNetPlanetBarcodeWriteOptions postNetPlanetWriteOptions = (PostNetPlanetBarcodeWriteOptions) writer 
         .getDefaultOptions(BarcodeSymbology.POST_NET); 
   postNetPlanetWriteOptions.setUseXModule(true); 
   assertTrue(postNetPlanetWriteOptions.getUseXModule() == true); 
 
   // Pharma code 
   PharmaCodeBarcodeWriteOptions pharmaCodeBarcodeWriteOptions = (PharmaCodeBarcodeWriteOptions) writer 
         .getDefaultOptions(BarcodeSymbology.PHARMA_CODE); 
   pharmaCodeBarcodeWriteOptions.setUseXModule(true); 
   pharmaCodeBarcodeWriteOptions.setXModule(30); 
   assertTrue(pharmaCodeBarcodeWriteOptions.getUseXModule() == true); 
 
   // We will use this object to save files 
   RasterCodecs codecs = new RasterCodecs(); 
 
   // Get all the available write symbologies 
   BarcodeSymbology[] symbologies = writer.getAvailableSymbologies(); 
   assertTrue(symbologies != null); 
   for (BarcodeSymbology symbology : symbologies) { 
      assertTrue(symbology != null); 
      System.out.printf("Processing %s%n", symbology); 
 
      // Create the default data for this symbology 
      BarcodeData data = BarcodeData.createDefaultBarcodeData(symbology); 
 
      // Calculate its size with default options 
      writer.calculateBarcodeDataBounds(LeadRect.getEmpty(), resolution, resolution, data, null); 
 
      // Create an image to write the data to 
      LeadRect pixels = data.getBounds(); 
      RasterImage image = RasterImage.create(pixels.getWidth(), pixels.getHeight(), 1, resolution, 
            RasterColor.fromKnownColor(RasterKnownColor.WHITE)); 
 
      // Write the barcode with default options 
      writer.writeBarcode(image, data, null); 
 
      // Save it 
      String outFileName = combine(outDir, symbology + ".tif"); 
      codecs.save(image, outFileName, RasterImageFormat.TIF, 1); 
      assertTrue((new File(outFileName)).exists()); 
   } 
} 
Requirements

Target Platforms

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

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