Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
This documentation provides a comprehensive guide on how to set the colorscheme for barcodes using the Aspose.BarCode Cloud SDK for .NET. The API allows customization of barcode appearance, including foreground and background colors, ensuring your barcodes match your design needs.
The IGenerateApi
interface includes methods to generate barcodes using different request formats:
The ForegroundColor
and BackgroundColor
properties enable you to define the colors for the barcode:
Both properties accept standard color names or ARGB values (e.g., AliceBlue
or #FF000000
).
using Aspose.BarCode.Cloud.Sdk.Api;
using Aspose.BarCode.Cloud.Sdk.Interfaces;
using Aspose.BarCode.Cloud.Sdk.Model;
using System;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
namespace GenerateSnippets;
internal static class Program
{
private static Configuration MakeConfiguration()
{
var config = new Configuration();
string? envToken = Environment.GetEnvironmentVariable("TEST_CONFIGURATION_ACCESS_TOKEN");
if (string.IsNullOrEmpty(envToken))
{
config.ClientId = "Client Id from https://dashboard.aspose.cloud/applications";
config.ClientSecret = "Client Secret from https://dashboard.aspose.cloud/applications";
}
else
{
config.JwtToken = envToken;
}
return config;
}
public static async Task Main(string[] args)
{
string fileName = Path.GetFullPath(Path.Join("Tests", "test_data",
"qr.png"
));
GenerateApi generateApi = new GenerateApi(MakeConfiguration());
Stream generated = await generateApi.GenerateAsync(EncodeBarcodeType.QR,
"https://products.aspose.cloud/barcode/family/",
foregroundColor: "DarkBlue",
backgroundColor: "LightGray",
imageFormat: BarcodeImageFormat.Png);
await using FileStream stream = File.Create(fileName);
await generated.CopyToAsync(stream);
Console.WriteLine($"File '{fileName}' generated.");
}
}
Result Image is:
using Aspose.BarCode.Cloud.Sdk.Api;
using Aspose.BarCode.Cloud.Sdk.Interfaces;
using Aspose.BarCode.Cloud.Sdk.Model;
using System;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
namespace GenerateSnippets;
internal static class Program
{
private static Configuration MakeConfiguration()
{
var config = new Configuration();
string? envToken = Environment.GetEnvironmentVariable("TEST_CONFIGURATION_ACCESS_TOKEN");
if (string.IsNullOrEmpty(envToken))
{
config.ClientId = "Client Id from https://dashboard.aspose.cloud/applications";
config.ClientSecret = "Client Secret from https://dashboard.aspose.cloud/applications";
}
else
{
config.JwtToken = envToken;
}
return config;
}
public static async Task Main(string[] args)
{
string fileName = Path.GetFullPath(Path.Join("Tests", "test_data",
"Pdf417.png"
));
GenerateApi generateApi = new GenerateApi(MakeConfiguration());
var generateParams = new GenerateParams
{
BarcodeType = EncodeBarcodeType.Pdf417,
EncodeData = new EncodeData { Data = "Aspose.BarCode.Cloud", DataType = EncodeDataType.StringData },
BarcodeImageParams = new BarcodeImageParams
{
ForegroundColor = "#FF5733",
BackgroundColor = "#FFFFFF",
ImageFormat = BarcodeImageFormat.Jpeg
}
};
Stream generated = await generateApi.GenerateBodyAsync(generateParams);
await using FileStream stream = File.Create(fileName);
await generated.CopyToAsync(stream);
Console.WriteLine($"File '{fileName}' generated.");
}
}
Result Image is:
using Aspose.BarCode.Cloud.Sdk.Api;
using Aspose.BarCode.Cloud.Sdk.Interfaces;
using Aspose.BarCode.Cloud.Sdk.Model;
using System;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
namespace GenerateSnippets;
internal static class Program
{
private static Configuration MakeConfiguration()
{
var config = new Configuration();
string? envToken = Environment.GetEnvironmentVariable("TEST_CONFIGURATION_ACCESS_TOKEN");
if (string.IsNullOrEmpty(envToken))
{
config.ClientId = "Client Id from https://dashboard.aspose.cloud/applications";
config.ClientSecret = "Client Secret from https://dashboard.aspose.cloud/applications";
}
else
{
config.JwtToken = envToken;
}
return config;
}
public static async Task Main(string[] args)
{
string fileName = Path.GetFullPath(Path.Join("Tests", "test_data",
"Code39.png"
));
GenerateApi generateApi = new GenerateApi(MakeConfiguration());
Stream generated = await generateApi.GenerateMultipartAsync(EncodeBarcodeType.Code39, "Aspose",
foregroundColor: "Green",
backgroundColor: "Yellow",
imageFormat: BarcodeImageFormat.Gif);
await using FileStream stream = File.Create(fileName);
await generated.CopyToAsync(stream);
Console.WriteLine($"File '{fileName}' generated.");
}
}
Result Image is:
With IGenerateApi
in Aspose.BarCode Cloud SDK for .NET, you can easily generate barcodes with customized colors. Whether you prefer GET, POST with JSON, or multipart form POST, the flexibility of this API ensures seamless integration and customization of barcodes in your applications.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.