Skip to content

Repository contains .NET Library for communicating with the Aspose.BarCode Cloud API

License

Notifications You must be signed in to change notification settings

aspose-barcode-cloud/aspose-barcode-cloud-dotnet

Repository files navigation

Aspose.BarCode Cloud SDK for .NET

License .NET Core Linux .NET Framework Windows Nuget

  • API version: 3.0
  • SDK version: 24.5.0

Demo applications

Scan QR Generate Barcode Recognize Barcode
ScanQR Generate Recognize
Generate Wi-Fi QR Embed Barcode Scan Barcode
Wi-FiQR Embed Scan

Aspose.BarCode for Cloud is a REST API for Linear, 2D and postal barcode generation and recognition in the cloud. API recognizes and generates barcode images in a variety of formats. Barcode REST API allows to specify barcode image attributes like image width, height, border style and output image format in order to customize the generation process. Developers can also specify the barcode type and text attributes such as text location and font styles in order to suit the application requirements.

This repository contains Aspose.BarCode Cloud SDK for .NET source code. This SDK allows you to work with Aspose.BarCode for Cloud REST APIs in your .NET Core or .NET Framework applications quickly and easily.

Aspose.BarCode Cloud SDK for .NET provides cross-platform bindings for:

  • .NET 5 and higher
  • .NET Standard 2.0 and higher
  • .NET Core 3.1 and higher
  • .NET Framework 4.6.2 and higher

To use these SDKs, you will need Client Id and Client Secret which can be looked up at Aspose Cloud Dashboard (free registration in Aspose Cloud is required for this).

How to use the SDK?

The complete source code is available in this repository folder. You can either directly use it in your project via source code or get NuGet distribution (recommended).

Prerequisites

To use Aspose.BarCode Cloud SDK for .NET you need to register an account with Aspose Cloud and lookup/create Client Secret and Client Id at Cloud Dashboard. There is free quota available. For more details, see Aspose Cloud Pricing.

Installation

Install Aspose.BarCode-Cloud via NuGet

From the command line:

nuget install Aspose.BarCode-Cloud

From Package Manager:

PM> Install-Package Aspose.BarCode-Cloud

From within Visual Studio:

  1. Open the Solution Explorer.
  2. Right-click on a project within your solution.
  3. Click on Manage NuGet Packages...
  4. Click on the Browse tab and search for "Aspose.BarCode-Cloud".
  5. Click on the Aspose.BarCode-Cloud package, select the appropriate version in the right-tab and click Install.

Recognize QR code

The examples below show how you can recognize QR code from image:

using Aspose.BarCode.Cloud.Sdk.Api;
using Aspose.BarCode.Cloud.Sdk.Interfaces;
using Aspose.BarCode.Cloud.Sdk.Model;
using Aspose.BarCode.Cloud.Sdk.Model.Requests;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;

namespace ReadQR;

internal static class Program
{
    private static Configuration MakeConfiguration()
    {
        var config = new Configuration();

        string? envToken = Environment.GetEnvironmentVariable("TEST_CONFIGURATION_JWT_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;
    }

    private static async Task<string> ReadQR(IBarcodeApi api, string fileName)
    {
        await using FileStream imageStream = File.OpenRead(fileName);
        BarcodeResponseList recognized = await api.ScanBarcodeAsync(
            new ScanBarcodeRequest(imageStream)
            {
                decodeTypes = new List<DecodeBarcodeType> { DecodeBarcodeType.QR }
            }
        );

        return recognized.Barcodes[0].BarcodeValue;
    }

    public static async Task Main(string[] args)
    {
        string fileName = Path.GetFullPath(Path.Join(
            Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location),
            "..", "..", "..", "..",
            "qr.png"
        ));

        var api = new BarcodeApi(MakeConfiguration());

        string result = await ReadQR(api, fileName);
        Console.WriteLine($"File '{fileName}' recognized, result: '{result}'");
    }
}

Generate QR code

The examples below show how you can generate QR code and save it into local file using Aspose.BarCode-Cloud library:

using Aspose.BarCode.Cloud.Sdk.Api;
using Aspose.BarCode.Cloud.Sdk.Interfaces;
using Aspose.BarCode.Cloud.Sdk.Model;
using Aspose.BarCode.Cloud.Sdk.Model.Requests;
using System;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;

namespace GenerateQR;

internal static class Program
{
    private static Configuration MakeConfiguration()
    {
        var config = new Configuration();

        string? envToken = Environment.GetEnvironmentVariable("TEST_CONFIGURATION_JWT_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;
    }

    private static async Task GenerateQR(IBarcodeApi api, string fileName)
    {
        await using Stream generated = await api.GetBarcodeGenerateAsync(
            new GetBarcodeGenerateRequest(
                EncodeBarcodeType.QR.ToString(),
                "QR code text")
            {
                TextLocation = CodeLocation.None.ToString(),
                format = "png"
            });
        await using FileStream stream = File.Create(fileName);
        await generated.CopyToAsync(stream);
    }

    public static async Task Main(string[] args)
    {
        string fileName = Path.GetFullPath(Path.Join(
            Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location),
            "..", "..", "..", "..",
            "qr.png"
        ));

        BarcodeApi api = new BarcodeApi(MakeConfiguration());

        await GenerateQR(api, fileName);
        Console.WriteLine($"File '{fileName}' generated.");
    }
}

Dependencies

Licensing

All Aspose.BarCode for Cloud SDKs, helper scripts and templates are licensed under MIT License.

Resources

Documentation for API Endpoints

All URIs are relative to https://api.aspose.cloud/v3.0

Class Method HTTP request Description
BarcodeApi GetBarcodeGenerate GET /barcode/generate Generate barcode.
BarcodeApi GetBarcodeRecognize GET /barcode/{name}/recognize Recognize barcode from a file on server.
BarcodeApi PostBarcodeRecognizeFromUrlOrContent POST /barcode/recognize Recognize barcode from an url or from request body. Request body can contain raw data bytes of the image with content-type "application/octet-stream". An image can also be passed as a form field.
BarcodeApi PostGenerateMultiple POST /barcode/generateMultiple Generate multiple barcodes and return in response stream
BarcodeApi PutBarcodeGenerateFile PUT /barcode/{name}/generate Generate barcode and save on server (from query params or from file with json or xml content)
BarcodeApi PutBarcodeRecognizeFromBody PUT /barcode/{name}/recognize Recognition of a barcode from file on server with parameters in body.
BarcodeApi PutGenerateMultiple PUT /barcode/{name}/generateMultiple Generate image with multiple barcodes and put new file on server
BarcodeApi ScanBarcode POST /barcode/scan Quickly scan a barcode from an image.
FileApi CopyFile PUT /barcode/storage/file/copy/{srcPath} Copy file
FileApi DeleteFile DELETE /barcode/storage/file/{path} Delete file
FileApi DownloadFile GET /barcode/storage/file/{path} Download file
FileApi MoveFile PUT /barcode/storage/file/move/{srcPath} Move file
FileApi UploadFile PUT /barcode/storage/file/{path} Upload file
FolderApi CopyFolder PUT /barcode/storage/folder/copy/{srcPath} Copy folder
FolderApi CreateFolder PUT /barcode/storage/folder/{path} Create the folder
FolderApi DeleteFolder DELETE /barcode/storage/folder/{path} Delete folder
FolderApi GetFilesList GET /barcode/storage/folder/{path} Get all files and folders within a folder
FolderApi MoveFolder PUT /barcode/storage/folder/move/{srcPath} Move folder
StorageApi GetDiscUsage GET /barcode/storage/disc Get disc usage
StorageApi GetFileVersions GET /barcode/storage/version/{path} Get file versions
StorageApi ObjectExists GET /barcode/storage/exist/{path} Check if file or folder exists
StorageApi StorageExists GET /barcode/storage/{storageName}/exist Check if storage exists

Documentation for Models