/**
  * Appends second tiff image to the original.
  *
  * @param string $appendFile The tiff image file to append.
  *
  * @return string|boolean
  * @throws Exception
  */
 public function appendTiff($appendFile = "")
 {
     //check whether file is set or not
     if ($appendFile == '') {
         throw new Exception('No file name specified');
     }
     $strURI = Product::$baseProductUri . '/imaging/tiff/' . $this->getFileName() . '/appendTiff?appendFile=' . $appendFile;
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'POST', '', '');
     $json = json_decode($responseStream);
     if ($json->Status == 'OK') {
         $folder = new Folder();
         $outputStream = $folder->getFile($this->getFileName());
         $outputPath = AsposeApp::$outPutLocation . $this->getFileName();
         Utils::saveFile($outputStream, $outputPath);
         return $outputPath;
     } else {
         return false;
     }
 }
 /**
  * Compare the currently active $this->fileName with the passed $compareWithFilename. Make sure
  * that $this->fileName does not have any pending revision changes.
  *
  * @see http://api.aspose.com/v1.1/swagger/ui/index#!/words/WordsDocumentSaveAs_PostDocumentSaveAs
  *
  * @param string $compareWithFilename
  * @param array $compareData
  * @param array $options
  *
  * @return bool
  * @throws Exception
  */
 public function compareDocument($compareWithFilename, array $compareData = array(), array $options = array())
 {
     // POST parameters
     $resolver = new OptionsResolver();
     $resolver->setDefault('ComparingWithDocument', $compareWithFilename)->setRequired(array('Author'))->setDefined(array('DateTime'));
     $compareData = json_encode($resolver->resolve($compareData));
     // GET parameters
     $resolver = new OptionsResolver();
     $resolver->setDefined(array('filename', 'storage', 'folder'));
     $options = $resolver->resolve($options);
     // Create request with resolved POST and GET parameters
     $strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/compareDocument?' . http_build_query($options);
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'POST', 'JSON', $compareData);
     $json = json_decode($responseStream);
     if ($json->Code == 200 && isset($json->Document)) {
         $outputFile = $json->Document->FileName;
         $folder = new Folder();
         $outputStream = $folder->getFile($outputFile);
         $outputPath = AsposeApp::$outPutLocation . $outputFile;
         Utils::saveFile($outputStream, $outputPath);
         return $outputPath;
     }
     AsposeApp::getLogger()->warning('Error occured while processing `compareDocument` command, HTTP 200 code or result `Document` was not found.', array('json-code' => $json->Code));
     return false;
 }
 /**
  * Executes mail merge with regions.
  *
  * @param string $fileName The name of source file.
  * @param string $strXML Data in xml format.
  * @param string $documentFolder Result name of the document after the operation
  * @param array $cleanUpParams If cleanup parameter is omitted, cleanup options will be None (None, EmptyParagraphs,
  * UnusedRegions, UnusedFields, ContainingFields, RemoveTitleRow, RemoveTitleRowInInnerTables)
  *
  * @return string Returns the file path.
  * @throws Exception
  */
 public function executeMailMergewithRegions($fileName, $strXML, $documentFolder = '', $cleanUpParams = array('None'))
 {
     //check whether files are set or not
     if ($fileName == '') {
         throw new Exception('File not specified');
     }
     //flatten cleanup params to string ready to append to uri
     $cleanUpString = '';
     foreach ($cleanUpParams as $cleanUpParam) {
         $cleanUpString .= strlen($cleanUpString) ? ',' . $cleanUpParam : $cleanUpParam;
     }
     //build URI to execute mail merge with regions
     $strURI = Product::$baseProductUri . '/words/' . $fileName . '/executeMailMerge?withRegions=true' . '&folder=' . $documentFolder . '&cleanup=' . $cleanUpString;
     //sign URI
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'POST', '', $strXML);
     $json = json_decode($responseStream);
     $v_output = Utils::validateOutput($responseStream);
     if ($v_output === '') {
         //Save docs on server
         $folder = new Folder();
         if ($documentFolder) {
             $outputStream = $folder->getFile($documentFolder . '/' . $json->Document->FileName);
         } else {
             $outputStream = $folder->getFile($json->Document->FileName);
         }
         $outputPath = AsposeApp::$outPutLocation . $fileName;
         Utils::saveFile($outputStream, $outputPath);
         return $outputPath;
     } else {
         return $v_output;
     }
 }
 /**
  * Update Form Fields in a PDF Document.
  *
  * @param array $fieldArray Fields in an array
  * @param string $documentFolder Where the template resides
  *
  * @return bool
  * @throws Exception
  */
 public function updateFormFields(array $fieldArray, $documentFolder = '')
 {
     if (count($fieldArray) === 0) {
         throw new Exception('Field array cannot be empty');
     }
     //build URI
     $strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/fields?folder=' . $documentFolder;
     //sign URI
     $signedURI = Utils::sign($strURI);
     $postData = json_encode(array('List' => $fieldArray));
     //get response stream
     $responseStream = Utils::processCommand($signedURI, 'PUT', 'JSON', $postData);
     $json = json_decode($responseStream);
     $v_output = Utils::validateOutput($responseStream);
     if ($v_output === '') {
         //Save docs on server
         $folder = new Folder();
         if ($documentFolder) {
             $outputStream = $folder->getFile($documentFolder . '/' . $this->getFileName());
         } else {
             $outputStream = $folder->getFile($this->getFileName());
         }
         $outputPath = AsposeApp::$outPutLocation . $this->getFileName();
         Utils::saveFile($outputStream, $outputPath);
         return $outputPath;
     } else {
         return $v_output;
     }
 }