コード例 #1
0
        public List<Paragraph> GetText(string FileName)
        {
            try
            {
                //build URI
                string strURI = Product.BaseProductUri + "/words/" + FileName;
                strURI += "/textItems";

                //sign URI
                string signedURI = Utils.Sign(strURI);

                StreamReader reader = new StreamReader(Utils.ProcessCommand(signedURI, "GET"));
                //further process JSON response
                string strJSON = reader.ReadToEnd();

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

                //List of text items in document
                List<Aspose.Cloud.Words.Paragraph> paragraphs = new List<Aspose.Cloud.Words.Paragraph>();

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

                paragraphs = docResponse.TextItems.List;

                return paragraphs;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #2
0
        /// <summary>
        /// Get Document's properties
        /// </summary>
        /// <returns>List of document properties</returns>
        public List<DocumentProperty> GetProperties()
        {
            try
            {
                //check whether file is set or not
                if (FileName == "")
                    throw new Exception("No file name specified");

                //build URI
                string strURI = Product.BaseProductUri + "/words/" + FileName;
                strURI += "/documentProperties";

                //sign URI
                string signedURI = Utils.Sign(strURI);

                StreamReader reader = new StreamReader(Utils.ProcessCommand(signedURI, "GET"));

                //further process JSON response
                string strJSON = reader.ReadToEnd();

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

                //Create list of document properties
                List<Aspose.Cloud.Words.DocumentProperty> properties = new List<Aspose.Cloud.Words.DocumentProperty>();

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

                properties = docResponse.DocumentProperties.List;

                //return document properties
                return properties;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }