How to Create Rotated BarCode in Java

This quick tutorial describes the procedure to create rotated barcode in Java. It is very common to use barcode images at various angles in documents or on the packings etc. based on particular design requirements. You can set barcode rotation in java having different sizes and orientations as per your requirement and save them as PNG or any other type of image.

Steps to Create Rotated Barcode in Java

  1. Configure your project to add Aspose.BarCode library from Maven Repository
  2. Instantiate a new instance of BarcodeGenerator and set the default encoding to Code128 using EncodeTypes
  3. Set some text to be encoded in the output barcode image
  4. Set the rotation angle of the output image by setting the desired number of degrees
  5. Save the output rotated barcode image as a PNG file on a disc

BarcodeGenerator class instance is required for creating and rotating barcodes in Java. It can be used to set default encoding, barcode text, and rotation angle in degrees. Ultimately you can save the rotated barcode image to PNG or any other type of image according to the environment.

Code to Set Barcode Rotation in Java

This sample code uses BarcodeGenerator class object to perform this task. For setting the encoding type the enumerator EncodeTypes is used which contains all the common encoding types used in a barcode. Similarly while saving the final output image, use the BarCodeImageFormat enumerator for selecting the image type.

This tutorial creates a rotated barcode image in Java however if you want to create a simple QR Code, refer to the article on how to generate QR Code using Java.

 English