Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
To perform barcode recognition using the Aspose.BarCode.Cloud SDK for .NET, you need to set the source of the barcode image. Methods of this SDK support loading barcode images from multiple sources, such as file URL, file stream, and base64 encoded data. This guide provides detailed examples on how to set barcode image source through different API methods.
using Aspose.BarCode.Cloud.Sdk.Api;
using Aspose.BarCode.Cloud.Sdk.Interfaces;
using Aspose.BarCode.Cloud.Sdk.Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
namespace ScanSnippets;
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)
{
var scanApi = new ScanApi(MakeConfiguration());
var result = await scanApi.ScanAsync("https://products.aspose.app/barcode/scan/img/how-to/scan/step2.png");
Console.WriteLine($"File recognized, result: '{result.Barcodes[0].BarcodeValue}'");
}
}
using Aspose.BarCode.Cloud.Sdk.Api;
using Aspose.BarCode.Cloud.Sdk.Interfaces;
using Aspose.BarCode.Cloud.Sdk.Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
namespace ScanSnippets;
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)
{
var scanApi = new ScanApi(MakeConfiguration());
string fileName = Path.GetFullPath(Path.Join("Tests", "test_data",
"qr.png"
));
byte[] imageBytes = await File.ReadAllBytesAsync(fileName);
string imageBase64 = Convert.ToBase64String(imageBytes);
var request = new ScanBase64Request
{
FileBase64 = imageBase64
};
var result = await scanApi.ScanBase64Async(request);
Console.WriteLine($"File '{fileName}' recognized, result: '{result.Barcodes[0].BarcodeValue}'");
}
}
using Aspose.BarCode.Cloud.Sdk.Api;
using Aspose.BarCode.Cloud.Sdk.Interfaces;
using Aspose.BarCode.Cloud.Sdk.Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
namespace ScanSnippets;
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)
{
var scanApi = new ScanApi(MakeConfiguration());
string fileName = Path.GetFullPath(Path.Join("Tests", "test_data",
"qr.png"
));
using var fileStream = new FileStream(fileName, FileMode.Open);
var result = await scanApi.ScanMultipartAsync(fileStream);
Console.WriteLine($"File '{fileName}' recognized, result: '{result.Barcodes[0].BarcodeValue}'");
}
}
using Aspose.BarCode.Cloud.Sdk.Api;
using Aspose.BarCode.Cloud.Sdk.Interfaces;
using Aspose.BarCode.Cloud.Sdk.Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
namespace RecgonizeSnippets;
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)
{
var recognizeApi = new RecognizeApi(MakeConfiguration());
var result = await recognizeApi.RecognizeAsync(DecodeBarcodeType.QR,
"https://products.aspose.app/barcode/scan/img/how-to/scan/step2.png");
Console.WriteLine($"File recognized, result: '{result.Barcodes[0].BarcodeValue}'");
}
}
using Aspose.BarCode.Cloud.Sdk.Api;
using Aspose.BarCode.Cloud.Sdk.Interfaces;
using Aspose.BarCode.Cloud.Sdk.Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
namespace RecognizeSnippets;
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)
{
var recognizeApi = new RecognizeApi(MakeConfiguration());
string fileName = Path.GetFullPath(Path.Join("Tests", "test_data",
"Pdf417.png"
));
byte[] imageBytes = await File.ReadAllBytesAsync(fileName);
string imageBase64 = Convert.ToBase64String(imageBytes);
var request = new RecognizeBase64Request
{
BarcodeTypes = new List<DecodeBarcodeType> { DecodeBarcodeType.Pdf417 },
FileBase64 = imageBase64
};
var result = await recognizeApi.RecognizeBase64Async(request);
Console.WriteLine($"File '{fileName}' recognized, result: '{result.Barcodes[0].BarcodeValue}'");
}
}
using Aspose.BarCode.Cloud.Sdk.Api;
using Aspose.BarCode.Cloud.Sdk.Interfaces;
using Aspose.BarCode.Cloud.Sdk.Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
namespace RecognizeSnippets;
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)
{
var recognizeApi = new RecognizeApi(MakeConfiguration());
string fileName = Path.GetFullPath(Path.Join("Tests", "test_data",
"qr.png"
));
using var fileStream = new FileStream(fileName, FileMode.Open);
var result = await recognizeApi.RecognizeMultipartAsync(DecodeBarcodeType.QR,
fileStream);
Console.WriteLine($"File '{fileName}' recognized, result: '{result.Barcodes[0].BarcodeValue}'");
}
}
Using the Aspose.BarCode.Cloud SDK for .NET, you can easily load and recognize barcode images in file URL, file stream, and base64 encoded formats.
Optimize your barcode recognition workflows by selecting the most appropriate method based on your specific image format and application requirements.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.