Пример #1
0
        /// <summary>
        /// Gets raw text from a particular page
        /// </summary>
        /// <returns></returns>
        public string GetText(int pageNumber)
        {
            //build URI to get page count
            string strURI    = Product.BaseProductUri + "/pdf/" + FileName + "/pages/" + pageNumber.ToString() + "/TextItems";
            string signedURI = Utils.Sign(strURI);

            Stream responseStream = Utils.ProcessCommand(signedURI, "GET");

            StreamReader reader  = new StreamReader(responseStream);
            string       strJSON = reader.ReadToEnd();


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


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


            StringBuilder stringBuilder = new StringBuilder();


            foreach (TextItem textItem in textItemsResponse.TextItems.List)
            {
                stringBuilder.Append(textItem.Text);
            }

            return(stringBuilder.ToString());
        }
Пример #2
0
        /// <summary>
        /// Gets count of segments in a fragment
        /// </summary>
        /// <param name="pageNumber"></param>
        /// <param name="fragmentNumber"></param>
        /// <returns></returns>
        public int GetSegmentCount(int pageNumber, int fragmentNumber)
        {
            //build URI to get page count
            string strURI    = Product.BaseProductUri + "/pdf/" + FileName + "/pages/" + pageNumber.ToString() + "/fragments/" + fragmentNumber.ToString();
            string signedURI = Utils.Sign(strURI);

            Stream responseStream = Utils.ProcessCommand(signedURI, "GET");

            StreamReader reader  = new StreamReader(responseStream);
            string       strJSON = reader.ReadToEnd();


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


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

            return(textItemsResponse.TextItems.List.Count);
        }