예제 #1
0
        /// <summary>
        /// Sets the value of a particular property
        /// </summary>
        /// <param name="propertyName"></param>
        /// <param name="propertyValue"></param>
        /// <returns></returns>
        public bool SetDocumentProperty(string propertyName, string propertyValue)
        {
            //build URI to get page count
            string strURI    = Product.BaseProductUri + "/pdf/" + FileName + "/documentProperties/" + propertyName;
            string signedURI = Utils.Sign(strURI);

            //serialize the JSON request content
            DocumentProperty docProperty = new DocumentProperty();

            docProperty.Value = propertyValue;
            string strJSON = JsonConvert.SerializeObject(docProperty);

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

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

            //Parse the json string to JObject
            JObject pJSON = JObject.Parse(strResponse);

            DocumentPropertyResponse baseResponse = JsonConvert.DeserializeObject <DocumentPropertyResponse>(pJSON.ToString());

            if (baseResponse.Code == "200" && baseResponse.Status == "OK")
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// Gets the value of a particular property
        /// </summary>
        /// <param name="propertyName"></param>
        /// <returns>value of the specified property</returns>
        public DocumentProperty GetDocumentProperty(string propertyName)
        {
            //build URI to get page count
            string strURI    = Product.BaseProductUri + "/pdf/" + FileName + "/documentProperties/" + propertyName;
            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.
            DocumentPropertyResponse documentPropertyResponse = JsonConvert.DeserializeObject <DocumentPropertyResponse>(parsedJSON.ToString());

            return(documentPropertyResponse.DocumentProperty);
        }