Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
This documentation covers how to set barcode text in the Aspose.BarCode Cloud SDK for .NET. The Barcode API supports multiple methods to generate barcodes in different formats using GET and POST requests through the IGenerateApi
. Barcodes can be generated by specifying various parameters such as barcode type, data to encode, image format and display options. The data encoding process involves defining the type of data and the actual content.
The IGenerateApi
interface includes methods for generating barcodes:
DataType
: Specifies the type of data encoding (can be string, base64, or hex). If not set, the Data
value is used as plain text.Data
: A string that represents the data to be encoded.Value | Description |
---|---|
StringData (Default value) | Plain text |
Base64Bytes | Base64 encoded binary data |
HexBytes | Hexadecimal encoded binary data |
Below are examples to demonstrate barcode generation using the IGenerateApi
methods.
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, "Aspose.BarCode.Cloud", dataType: EncodeDataType.StringData);
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
{
DataType = EncodeDataType.Base64Bytes,
Data = "QXNwb3NlLkJhckNvZGUuQ2xvdWQ="
}
};
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",
"Code128.png"
));
GenerateApi generateApi = new GenerateApi(MakeConfiguration());
Stream generated = await generateApi.GenerateMultipartAsync(EncodeBarcodeType.Code128, "4173706F73652E426172436F64652E436C6F7564", dataType: EncodeDataType.HexBytes);
await using FileStream stream = File.Create(fileName);
await generated.CopyToAsync(stream);
Console.WriteLine($"File '{fileName}' generated.");
}
}
Result Image is:
This documentation covers how to use the IGenerateApi
to set barcodes text.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.