generate barcode

Generate Barcode in Custom Colors with .NET REST API.

In a world where barcodes are ubiquitous and play a vital role in diverse applications, the need for customizing their appearance, particularly their colors, has never been more pronounced. The Barcodes are not merely utilitarian; they have evolved into a visual representation of a brand or a product. Therefore, customizing barcode colors is no longer an option, but it’s a necessity. So, whether it’s about maintaining brand consistency, enhancing user experience, or simply integrating seamlessly with a design, the ability to customize barcode colors is a crucial requirement.

This article unveils the significance and the myriad benefits of this customization using .NET REST API.

.NET Cloud SDK for Barcode Customization

Unlocking the potential of barcode customization is effortless with the Aspose.BarCode Cloud SDK for .NET. This powerful toolkit allows you to seamlessly integrate the ability to customize barcode colors in your applications. With this SDK, the customization goes beyond colors, and you can tailor various aspects of barcodes, including their symbology, size, resolution, and more. Also, please note that the SDK ensures consistent and accurate barcode generation, adhering to industry standards.

Now, in order to use the SDK, first we need to search Aspose.BarCode-Cloud in NuGet packages manager and click the Add Package button. Secondly, we need to visit cloud dashboard, to obtain your personalized client credentials.

Customize Barcode in C# .NET

Usually, barcode images have a black-and-white color scheme. However, this REST API enables customizing system RGB colors for key barcode elements, including:

  • Bars
  • Background
  • Borders
  • Text label
  • Top and bottom captions

Set Bars Color

In order to set the color for Bars, we need to set the value for BarColor property of GetBarcodeGenerateRequest class. The default value is Black.

barcode bar color

Preview of custom bar color for Barcode.

Background Color

The Barcode background color can be modified using BackColor property in GetBarcodeGenerateRequest class. The default background color value is White.

barcode background color

Preview of Barcode with Background color.

Custom Border and Color

We also have the flexibility to set custom border style as well as custom color information for the border.

  • Possible values for border style are Solid, Dash, Dot, DashDot, DashDotDot.
barcode border

Preview of custom border for Barcode.

Barcode Text Label Formatting

We also have the leverage to control the color and positioning of barcode label. In the code snippet below, we have set the barcode label/text position as Top and Right justified, with color information as Gold. For better presentation, we have also set the background color as Navy.

set barcode text color

Preview of Barcode with custom text color.

Generate Custom BarCode using cURL Commands

Customizing barcode colors and leveraging the capabilities of Aspose.Barcode Cloud using cURL commands is a seamless and efficient process. With this API, you can easily alter the colors of barcodes to match your specific requirements and design preferences. Additionally, using cURL commands, you can effortlessly generate and customize barcodes by adjusting various parameters such as symbology, size, resolution, and more.

So, the first step is to execute the following command to generate a JWT access token:

curl -v "https://api.aspose.cloud/connect/token" \
 -X POST \
 -d "grant_type=client_credentials&client_id=163c02a1-fcaa-4f79-be54-33012487e783&client_secret=c71cfe618cc6c0944f8f96bdef9813ac" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Accept: application/json"

Once we have the JWT token, please execute the following command to generate a barcode containing custom text color, custom border color, border pattern, different background color and rotated at 45 Degree angle.

curl -v "https://api.aspose.cloud/v3.0/barcode/generate?Type=Code93Standard&Text=Hello%20World...%20!&TextLocation=Below&TextAlignment=Center&TextColor=Gold&FontSizeMode=Auto&Resolution=100&RotationAngle=-45&BarColor=Navy&BorderColor=Maroon&BorderWidth=5&BorderDashStyle=DashDot&BorderVisible=true&FilledBars=true&UseAntiAlias=true&format=PNG" \
-X GET \
-H "accept: image/png" \
-H "authorization: Bearer {accessToken}"
-o "resultantBarcode.png"

Replace accessToken with JWT access token generated above.

bar code generation

Preview of customized Barcode.

Conclusion

In conclusion, the ability to customize barcode colors and utilize the comprehensive capabilities of Aspose.Barcode, whether through the dedicated .NET REST API or via cURL commands with Aspose.Barcode Cloud, stands as a testament to the evolving landscape of barcode integration and management. The dedicated .NET REST API offers a seamless and developer-friendly experience, providing a plethora of customization options beyond colors, ensuring precise control over various aspects of barcode design. On the other hand, the integration of Aspose.Barcode Cloud through cURL commands presents a versatile and accessible approach, catering to a broader audience and empowering efficient barcode customization.

We highly recommend visiting the following blogs: