Java UPC-A Generator Size Setting Tutorial

sample source code to generate linear UPC-A images and adjust barcode size in Java


  • Java UPC-A generation component supports rotating UPC-A image with 0, 90, 180, 270 angles
  • autoResize can adjust the generated UPC-A barcode image in Java automatically
  • UPC-A image width in Java can be changed with Y (bar height), barcodeHeight, topMargin and bottomMargin
  • Pre-configured industry standards UPC-A allow any untrained users to insert UPC-A in Java
  • Java Server Side projects (JSP, Servlet, EJB, J2EE, Web Service) can be easily integrated
  • Java Client applications (Java Class, Swing, Applet, Java Bean and J2SE) are supported
  • Supports Java Reports software to set your wanted size of UPC-A
  • Generate and print UPC-A in JDK 1.4.0 and later version

UPC-A, also known as Universal Product Code version A , UPC Code, UPC Symbol, GTIN-12, GS1-12, UCC-12, is the most common and well-known barcode symbology in the United States.

Java UPC-A image setting focus on setting UPC-A foreground color, bar color, background color, resolutin, rotation properties on Java;

Java UPC-A data encoding focus on setting UPC-A linear barcode valid encoding data, supplement data with valid data length and supplement data length.


UPC-A in Java Size Concerned Properties

  • supSpace: the space value between the UPC-A and the supplement barcode image in Java, default is 15 pixel.
  • supHeight: the height of the supplement barcode. The default is 0.8 (80% of Y - bar module height).
  • X: Width of UPC-A bar module (narrow bar), default is 1 pixel.
  • barcodeWidth: Generated UPC-A barcode image width, default value is 0 pixel.
  • leftMargin: UPC-A image left margin size, default value is 0 pixel.
  • rightMargin: UPC-A image right margin size, default value is 0 pixel.
  • Y: Height of UPC-A bar module, default is 30 pixel.
  • barcodeHeight: Generated UPC-A barcode image height, default value is 0 pixel.
  • topMargin: UPC-A image top margin size, default value is 0 pixel.
  • bottomMargin: UPC-A image bottom margin size, default value is 0 pixel.
  • autoResize: Auto resize the generated UPC-A barcode image.
  • uom: Unit of meature for all size related settings in the Java barcode library. Valid values: 0: pixel; 1: inch; 2: cm.
  • textMargin: Space between barcode and printed barcode data, default is 6 pixel.
  • textFont: UPC-A text (printed below barcode) font style, default is (new Font("Arial", 0, 12)).


Aspects on how to Change the Size of UPC-A in Java

Java UPC-A generator supports all UPC-A size related solution to specify the UPC-A images generated in Java. After purchasing the UPC-A generator for Java, please install and set up it, then copy the following code into your Java IntelliJ IDEA:

      UPCA barcode = new UPCA();
//UPC-A in java can only encode 11 numeric digits without autom check sum digit barcode.setData("12345678912");

Then, modify the following properties you may need:

UPC-A Bar Module Setting Properties in Java

Java UPC-A bar module size can be set with bar width (X), bar height (Y), supplement height (supHeight)

      barcode.setX(2f);
barcode.setY(80f);
barcode.setsupHeight(70f);

Java UPC-A Space Settings

Linear barcode UPC-A size can be adjusted with the space setting properties, excluding UPC-A bar module setting properties, which are left margin, rihgt margin, top margin, bottom margin and supspace.

      barcode.setLeftMargin(0f);
barcode.setRightMargin(0f);
barcode.setTopMargin(0f);
barcode.setBottomMargin(0f);
barcode.setsupSpace(25);

Java UPC-A Text Setting Properties

      //Set the show text to be true for adjustment in Java
      barcode.setShowText(true);
barcode.setTextFont(new Font("Arial", 0, 12));
barcode.setTextMargin(6);

Java UPC-A Overall Size Setting Properties

UPC-A image generaterd in Java may needs to be generated in larger size than pixel in some specific package and propducts, and unit of measure with Pixel, Inch and CM is required here in this situation.

      barcode.setUom(IBarcode.UOM_CM);

Notes: During setting the UPC-A width with the concerned properties, you need to pay attention that after you set a fixed bar width (X), an auto barcode width - minimum barcode width will be set in Java applications. However, if the set barcodeWidth value is less than the minimum barcode width, the created UPC-A image width in Java will be the minimum value. If the set barcodeWith is larger than the minimum one, the extra width will be added on the right and left margins in Java.

For UPC-A image height adjustment, the situation is as same as UPC-A image width adjustment.





OnBarcode is a market-leading provider of barcode generator, reader controls and components for ASP.NET, Windows Forms, WPF, as well Java, Android, iOS (iPhone, iPad) across all major enterprise development platforms. We provides high quality tutorials and guides for various linear, 2d barcode information, such as C# Barcode, QR Code C#, QR Code VB.NET, QR Code ASP.NET, QR Code .NET, ASP.NET Barcode. OnBarcode barcode products are supported by RasterEdge ASP.NET Document Viewer, which supports ASP.NET PDF Viewer, ASP.NET MVC Document Viewer, ASP.NET PDF Editor, MVC PDF Viewer. And provide high quality C# Convert PDF to Tiff, C# Convert PDF to Word, C# Convert PDF to HTML, C# Convert PDF to Jpeg images, and their easy and simple documents, like C# PDF SDK, C# extract text from PDF, C# Compress PDF, Print PDF in C# and C# extract image from PDF.
Terms of Use | Privacy Policy
Copyright © OnBarcode.com . All rights reserved.