|
13 | 13 |
|
14 | 14 | ## Demo applications |
15 | 15 |
|
16 | | -[Generate Barcode](https://products.aspose.app/barcode/generate) | [Recognize Barcode](https://products.aspose.app/barcode/recognize) | [Embed Barcode](https://products.aspose.app/barcode/embed) |
17 | | -:---: | :---: | :---: |
18 | | -[](https://products.aspose.app/barcode/generate) | [](https://products.aspose.app/barcode/recognize) | [](https://products.aspose.app/barcode/embed) |
| 16 | +[Scan QR](https://products.aspose.app/barcode/scanqr) | [Generate Barcode](https://products.aspose.app/barcode/generate) | [Recognize Barcode](https://products.aspose.app/barcode/recognize) | [Embed Barcode](https://products.aspose.app/barcode/embed) |
| 17 | +:---: | :---: | :---: | :---: |
| 18 | +[](https://products.aspose.app/barcode/scanqr) | [](https://products.aspose.app/barcode/generate) | [](https://products.aspose.app/barcode/recognize) | [](https://products.aspose.app/barcode/embed) |
19 | 19 |
|
20 | 20 | [Aspose.BarCode for Cloud](https://products.aspose.cloud/barcode/) 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. |
21 | 21 |
|
22 | | -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 Standard applications quickly and easily. |
| 22 | +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. |
23 | 23 |
|
24 | 24 | Aspose.BarCode Cloud SDK for .NET provides cross-platform bindings for: |
25 | 25 |
|
26 | | -- .NET Standard 2.0 |
27 | | -- .NET Framework 2.0 and higher |
| 26 | +- .NET Standard 2.0 and higher |
| 27 | +- .NET Core 2.1 and higher |
| 28 | +- .NET Framework 4.6.1 and higher |
28 | 29 |
|
29 | 30 | To use these SDKs, you will need Client Id and Client Secret which can be looked up at [Aspose Cloud Dashboard](https://dashboard.aspose.cloud/applications) (free registration in Aspose Cloud is required for this). |
30 | 31 |
|
@@ -58,27 +59,142 @@ From within Visual Studio: |
58 | 59 | 4. Click on the *Browse* tab and search for "Aspose.BarCode-Cloud". |
59 | 60 | 5. Click on the Aspose.BarCode-Cloud package, select the appropriate version in the right-tab and click *Install*. |
60 | 61 |
|
61 | | -## Sample usage |
| 62 | +## Recognize QR code |
62 | 63 |
|
63 | | -The examples below show how you can generate Code128 barcode and save it into local file using Aspose.BarCode-Cloud library: |
| 64 | +The examples below show how you can recognize QR code from image: |
64 | 65 |
|
65 | 66 | ```csharp |
66 | | -const string clientId = "Client Id from https://dashboard.aspose.cloud/applications"; |
67 | | -const string clientSecret = "Client Secret from https://dashboard.aspose.cloud/applications"; |
| 67 | +using Aspose.BarCode.Cloud.Sdk.Api; |
| 68 | +using Aspose.BarCode.Cloud.Sdk.Interfaces; |
| 69 | +using Aspose.BarCode.Cloud.Sdk.Model; |
| 70 | +using Aspose.BarCode.Cloud.Sdk.Model.Requests; |
| 71 | +using System; |
| 72 | +using System.IO; |
| 73 | +using System.Reflection; |
| 74 | + |
| 75 | +namespace ReadQR |
| 76 | +{ |
| 77 | + class Program |
| 78 | + { |
| 79 | + static Configuration MakeConfiguration() |
| 80 | + { |
| 81 | + var config = new Configuration(); |
| 82 | + |
| 83 | + var envToken = Environment.GetEnvironmentVariable("TEST_CONFIGURATION_JWT_TOKEN"); |
| 84 | + if (string.IsNullOrEmpty(envToken)) |
| 85 | + { |
| 86 | + config.ClientId = "Client Id from https://dashboard.aspose.cloud/applications"; |
| 87 | + config.ClientSecret = "Client Secret from https://dashboard.aspose.cloud/applications"; |
| 88 | + } |
| 89 | + else |
| 90 | + { |
| 91 | + config.JwtToken = envToken; |
| 92 | + } |
| 93 | + |
| 94 | + return config; |
| 95 | + } |
| 96 | + |
| 97 | + static string ReadQR(IBarcodeApi api, string fileName) |
| 98 | + { |
| 99 | + using (FileStream imageStream = File.OpenRead(fileName)) |
| 100 | + { |
| 101 | + BarcodeResponseList recognized = api.PostBarcodeRecognizeFromUrlOrContent( |
| 102 | + new PostBarcodeRecognizeFromUrlOrContentRequest(image: imageStream) |
| 103 | + ); |
| 104 | + |
| 105 | + return recognized.Barcodes[0].BarcodeValue; |
| 106 | + } |
| 107 | + } |
| 108 | + |
| 109 | + static void Main(string[] args) |
| 110 | + { |
| 111 | + string fileName = Path.GetFullPath(Path.Join( |
| 112 | + Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), |
| 113 | + "..", "..", "..", "..", |
| 114 | + "qr.png" |
| 115 | + )); |
| 116 | + |
| 117 | + var api = new BarcodeApi(MakeConfiguration()); |
| 118 | + |
| 119 | + string result = ReadQR(api, fileName); |
| 120 | + Console.WriteLine($"File '{fileName}' recognized, result: '{result}'"); |
| 121 | + } |
| 122 | + } |
| 123 | +} |
68 | 124 |
|
69 | | -var api = new BarcodeApi(clientSecret, clientId); |
| 125 | +``` |
| 126 | + |
| 127 | +## Generate QR code |
| 128 | + |
| 129 | +The examples below show how you can generate QR code and save it into local file using Aspose.BarCode-Cloud library: |
| 130 | + |
| 131 | +```csharp |
| 132 | +using Aspose.BarCode.Cloud.Sdk.Api; |
| 133 | +using Aspose.BarCode.Cloud.Sdk.Interfaces; |
| 134 | +using Aspose.BarCode.Cloud.Sdk.Model; |
| 135 | +using Aspose.BarCode.Cloud.Sdk.Model.Requests; |
| 136 | +using System; |
| 137 | +using System.IO; |
| 138 | +using System.Reflection; |
| 139 | + |
| 140 | +namespace GenerateQR |
| 141 | +{ |
| 142 | + class Program |
| 143 | + { |
| 144 | + static Configuration MakeConfiguration() |
| 145 | + { |
| 146 | + var config = new Configuration(); |
| 147 | + |
| 148 | + var envToken = Environment.GetEnvironmentVariable("TEST_CONFIGURATION_JWT_TOKEN"); |
| 149 | + if (string.IsNullOrEmpty(envToken)) |
| 150 | + { |
| 151 | + config.ClientId = "Client Id from https://dashboard.aspose.cloud/applications"; |
| 152 | + config.ClientSecret = "Client Secret from https://dashboard.aspose.cloud/applications"; |
| 153 | + } |
| 154 | + else |
| 155 | + { |
| 156 | + config.JwtToken = envToken; |
| 157 | + } |
| 158 | + |
| 159 | + return config; |
| 160 | + } |
| 161 | + |
| 162 | + static void GenerateQR(IBarcodeApi api, string fileName) |
| 163 | + { |
| 164 | + using (Stream generated = api.GetBarcodeGenerate( |
| 165 | + new GetBarcodeGenerateRequest( |
| 166 | + EncodeBarcodeType.QR.ToString(), |
| 167 | + "QR code text", |
| 168 | + textLocation: "None", format: "png")) |
| 169 | + ) |
| 170 | + { |
| 171 | + using (FileStream stream = File.Create(fileName)) |
| 172 | + { |
| 173 | + generated.CopyTo(stream); |
| 174 | + } |
| 175 | + } |
| 176 | + } |
| 177 | + |
| 178 | + static void Main(string[] args) |
| 179 | + { |
| 180 | + string fileName = Path.GetFullPath(Path.Join( |
| 181 | + Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), |
| 182 | + "..", "..", "..", "..", |
| 183 | + "qr.png" |
| 184 | + )); |
| 185 | + |
| 186 | + var api = new BarcodeApi(MakeConfiguration()); |
| 187 | + |
| 188 | + GenerateQR(api, fileName); |
| 189 | + Console.WriteLine($"File '{fileName}' generated."); |
| 190 | + } |
| 191 | + } |
| 192 | +} |
70 | 193 |
|
71 | | -using Stream response = api.GetBarcodeGenerate( |
72 | | - new GetBarcodeGenerateRequest( |
73 | | - EncodeBarcodeType.Code128.ToString(), "Sample text", format: "png") |
74 | | - ); |
75 | | -using FileStream stream = File.Create("out.png"); |
76 | | -response.CopyTo(stream); |
77 | 194 | ``` |
78 | 195 |
|
79 | 196 | ## Dependencies |
80 | 197 |
|
81 | | -- .NET Framework 2.0 or later, .NET Standard 2.0 |
82 | 198 | - [Json.NET](https://www.nuget.org/packages/Newtonsoft.Json/) |
83 | 199 |
|
84 | 200 | ## Licensing |
|
0 commit comments