←Select platform

BarcodeOutputTextPosition Enumeration

Summary
The text position to use when the data string is written along with the barcode.
Syntax
C#
Objective-C
C++/CLI
Java
Python
[SerializableAttribute()] 
public enum BarcodeOutputTextPosition   
typedef NS_ENUM(NSInteger, LTBarcodeOutputTextPosition) { 
 LTBarcodeOutputTextPositionNone,  
 LTBarcodeOutputTextPositionDefault,  
 LTBarcodeOutputTextPositionTop 
}; 
public enum BarcodeOutputTextPosition 
[SerializableAttribute()] 
public enum class BarcodeOutputTextPosition   
class BarcodeOutputTextPosition(Enum): 
   None = 0 
   Default = 1 
   Top = 2 
Members
Value Member Description
0 None No text string in the output if supported by the symbology, otherwise, behaves as Default.
1 Default Default text position as defined in the symbology standard, usually below the barcode. If no text output is supported by the symbology, behaves as None.
2 Top Top of the barcode when supported by the symbology. Otherwise, behaves as Default.
Remarks

The BarcodeOutputTextPosition is used as the type of the following properties: OneDBarcodeWriteOptions.TextPosition and FourStateBarcodeWriteOptions.TextPosition.

These properties control whether the data string is written along with the barcode and if so, its position. Note that not all symbologies support all the position values. Some symbologies allow you to control the text position completely (none, default or top), while some will only let you specify whether the text is written or not but not the location (default or none). Other symbologies will always require the text to be written (default). Refer to the Barcode symbology standard you are interested in or try it with the C# Barcode demo. Writing the text with the barcode is supported only by 1D linear barcodes. The following 1D linear barcode symbologies do not support setting the barcode text string at the bottom (below the barcode) regardless of the value of OneDBarcodeWriteOptions.TextPosition:

Example

This example writes a UPC-A barcode using different text positions.

C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Barcode; 
using Leadtools.ImageProcessing; 
 
 
public void BarcodeWriteOptions_BarcodeOutputTextPositionExample() 
{ 
   BarcodeEngine barcodeEngine = new BarcodeEngine(); 
 
   // Create a directory to store the image we will create 
   string outDir = Path.Combine(LEAD_VARS.ImagesDir, "MyBarcodes"); 
   if (Directory.Exists(outDir)) 
   { 
      Directory.Delete(outDir, true); 
   } 
   Directory.CreateDirectory(outDir); 
 
   // Create an image to save to 
   using (RasterImage image = RasterImage.Create(2550, 3300, 24, 300, RasterColor.White)) 
   { 
      // Create the sample barcode data 
      BarcodeData data = new BarcodeData 
      { 
         Symbology = BarcodeSymbology.UPCA, 
         Value = "01234567890", 
         Bounds = new LeadRect(150, 150, 600, 200) 
      }; 
 
      // Use options to change BarcodeOutputTextPosition 
      OneDBarcodeWriteOptions options = new OneDBarcodeWriteOptions 
      { 
         EnableErrorCheck = true, 
         TextPosition = BarcodeOutputTextPosition.Top 
      }; 
 
      // Write the barcode 
      barcodeEngine.Writer.WriteBarcode(image, data, options); 
 
      // Create the output file 
      string outFileName = Path.Combine(outDir + ".tif"); 
 
      // Save the image 
      using (RasterCodecs codecs = new RasterCodecs()) 
         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 barcodeOutputTextPositionExample() { 
   BarcodeEngine barcodeEngine = new BarcodeEngine(); 
 
   // Create a directory to store the image 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(); 
 
   // Create an image to save to 
   RasterImage image = RasterImage.create(2550, 3300, 24, 300, RasterColor.WHITE); 
   assertTrue(image != null); 
 
   // Create the sample barcode data 
   BarcodeData data = new BarcodeData(); 
   data.setSymbology(BarcodeSymbology.UPC_A); 
   assertTrue(data.getSymbology() == BarcodeSymbology.UPC_A); 
   data.setValue("01234567890"); 
   System.out.println(data.getValue()); 
   assertTrue(data.getValue() != null); 
   data.setBounds(new LeadRect(150, 150, 600, 200)); 
   assertTrue(data.getBounds() != null); 
 
   // Use options to change BarcodeOutputTextPosition 
   OneDBarcodeWriteOptions options = new OneDBarcodeWriteOptions(); 
 
   options.setEnableErrorCheck(true); 
   options.setTextPosition(BarcodeOutputTextPosition.TOP); 
   // Write the barcode 
   barcodeEngine.getWriter().writeBarcode(image, data, options); 
 
   // Create the output file 
   String outFileName = combine(outDir, ".tif"); 
 
   // Save the image 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.save(image, outFileName, RasterImageFormat.TIF, 1); 
   assertTrue((new File(outFileName)).exists()); 
} 
Requirements

Target Platforms

See Also

Reference

Leadtools.Barcode Namespace

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.