Example #1
0
        /// <summary>
        /// Read barcode from URL
        /// </summary>
        /// <param name="url">A URL containing image e.g. http://www.yourdomain.com/folder/images/code39.png </param>
        /// <param name="readType">type of barcode to be recognized</param>
        /// <returns>The response from Saaspose service</returns>
        /// <example>
        /// BarCodeReader reader = new BarCodeReader();
        /// List<RecognizedBarCode> barcodesRead = serverReader.Read("http://upload.wikimedia.org/wikipedia/commons/c/ce/WikiQRCode.png", BarCodeReadType.AllSupportedTypes);
        /// Console.WriteLine("Read from URL.");
        /// foreach (RecognizedBarCode barcodeRead in barcodesRead)
        /// {
        ///     Console.WriteLine("Codetext: " + barcodeRead.BarCodeValue + "\nType: " + barcodeRead.BarCodeType);
        /// }
        /// </example>
        public List <RecognizedBarCode> Read(string url, BarCodeReadType readType)
        {
            // Only validate the API keys
            PerformValidations(true);

            // Build URI for accessing Aspose.Cloud.BarCode API
            string uri = UriBuilderForURLImage(url, readType);

            // Send the request to Saaspose server
            Stream       responseStream = Utils.ProcessCommand(Utils.Sign(uri), "POST");
            StreamReader reader         = new StreamReader(responseStream);
            // Read the response
            string strJSON = reader.ReadToEnd();

            //Parse the json string to JObject
            JObject parsedJSON = JObject.Parse(strJSON);


            //Deserializes the JSON to a object.
            RecognitionResponse barcodeRecognitionResponse = JsonConvert.DeserializeObject <RecognitionResponse>(parsedJSON.ToString());

            return(barcodeRecognitionResponse.Barcodes);
        }
Example #2
0
        /// <summary>
        /// Read barcode from image on Saaspose server.
        /// </summary>
        /// <param name="remoteImageName">Remote image file name.</param>
        /// <param name="remoteFolder">Optional. Specify folder path to locate the image.</param>
        /// <param name="readType">Barcode type</param>
        /// <returns>List of recognized barcodes</returns>
        /// <example>
        /// BarCodeReader reader = new BarCodeReader();
        /// List<RecognizedBarCode> barcodesRead = reader.Read("test-1234.png", "", BarCodeReadType.AllSupportedTypes);
        /// Console.WriteLine("Read from server.");
        /// foreach (RecognizedBarCode barcodeRead in barcodesRead)
        /// {
        ///     Console.WriteLine("Codetext: " + barcodeRead.BarCodeValue + "\nType: " + barcodeRead.BarCodeType);
        /// }
        /// </example>
        public List <RecognizedBarCode> Read(string remoteImageName, string remoteFolder, BarCodeReadType readType)
        {
            _remoteImageName = remoteImageName;

            PerformValidations(false);

            // Build URL with querystring request parameters
            string uri = UriBuilder(remoteImageName, remoteFolder, readType);

            // Send the request to Saaspose server
            Stream       responseStream = Utils.ProcessCommand(Utils.Sign(uri), "GET");
            StreamReader reader         = new StreamReader(responseStream);
            // Read the response
            string strJSON = reader.ReadToEnd();

            //Parse the json string to JObject
            JObject parsedJSON = JObject.Parse(strJSON);


            //Deserializes the JSON to a object.
            RecognitionResponse barcodeRecognitionResponse = JsonConvert.DeserializeObject <RecognitionResponse>(parsedJSON.ToString());

            return(barcodeRecognitionResponse.Barcodes);
        }