Ejemplo n.º 1
0
 /**
  * Update a Form Field in a PDF Document.
  *  
  * @param string $fieldName The name of the field.
  * @param string $fieldType A value indicating the type of the form field. Available values - text, boolean, integer, list.
  * @param string $fieldValue The value of the form field.
  * 
  * @return object|boolean
  * @throws Exception
  */
 public function updateFormField($fieldName, $fieldType, $fieldValue)
 {
     if ($fieldName == '') {
         throw new Exception('Field name not specified');
     }
     if ($fieldType == '') {
         throw new Exception('Field type not specified');
     }
     if ($fieldValue == '') {
         throw new Exception('Field value not specified');
     }
     //build URI
     $strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/fields/' . $fieldName;
     //sign URI
     $signedURI = Utils::sign($strURI);
     $postData = json_encode(array("Name" => $fieldName, "Type" => $fieldType, "Values" => array($fieldValue)));
     //get response stream
     $responseStream = Utils::ProcessCommand($signedURI, 'PUT', 'JSON', $postData);
     $json = json_decode($responseStream);
     if ($json->Code == 200) {
         return $json->Field;
     } else {
         return false;
     }
 }
 public function getFormField($fieldName)
 {
     //build URI
     $strURI = Product::$baseProductUri . '/pdf/' . $this->fileName . '/fields/' . $fieldName;
     //sign URI
     $signedURI = Utils::sign($strURI);
     //get response stream
     $responseStream = Utils::ProcessCommand($signedURI, 'GET', '');
     $json = json_decode($responseStream);
     return $json->Field;
 }