/**
  * Convert web pages to Word Documents
  * 
  * @param XML $strXML Provide XML data.
  * 
  * @return string
  * @throws Exception
  */
 public function convertWebPages($strXML)
 {
     if ($strXML == '') {
         throw new Exception('XML not specified');
     }
     //build URI
     $strURI = Product::$baseProductUri . '/words/loadWebDocument';
     //sign URI
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'POST', 'XML', $strXML);
     $xml = simplexml_load_string($responseStream);
     if ($xml->Status == 'OK') {
         $fileName = $xml->SaveResult->Dest['href'];
         $strURI = Product::$baseProductUri . '/storage/file/' . $fileName;
         $signedURI = Utils::Sign($strURI);
         $responseStream = Utils::processCommand($signedURI, "GET", "", "");
         $outputPath = AsposeApp::$outPutLocation . $fileName;
         Utils::saveFile($responseStream, $outputPath);
         return $outputPath;
     } else {
         return false;
     }
 }
 /**
  * Clear Cells Formatting in Excel Worksheet
  * 
  * @param type $startRow Start row index.
  * @param type $startColumn Start column index.
  * @param type $endRow End row index.
  * @param type $endColumn End column index.
  * 
  * @return string Returns the file path.
  * @throws Exception
  */
 public function clearCellsFormatting($startRow, $startColumn, $endRow, $endColumn)
 {
     if ($startRow == '') {
         throw new Exception('Start Row not specified');
     }
     if ($startColumn == '') {
         throw new Exception('Start Column not specified');
     }
     if ($endRow == '') {
         throw new Exception('End Row not specified');
     }
     if ($endColumn == '') {
         throw new Exception('End Column not specified');
     }
     //Build URI
     $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $this->worksheetName . '/cells/ClearFormats?startRow=' . $startRow . '&startColumn=' . $startColumn . '&endRow=' . $endRow . '&endColumn=' . $endColumn;
     //Sign URI
     $signedURI = Utils::sign($strURI);
     //Send request and receive response stream
     $responseStream = Utils::processCommand($signedURI, 'POST', '', '');
     $v_output = Utils::validateOutput($responseStream);
     if ($v_output == '') {
         $strURI = Product::$baseProductUri . '/storage/file/' . $this->getFileName();
         $signedURI = Utils::Sign($strURI);
         $responseStream = Utils::processCommand($signedURI, "GET", "", "");
         $outputPath = AsposeApp::$outPutLocation . $this->getFileName();
         Utils::saveFile($responseStream, $outputPath);
         return $outputPath;
     } else {
         return $v_output;
     }
 }
 /**
  * @param array $options that will get processed using a OptionsResolver
  * <ul>
  *  <li>'from' => (int) page number,</li>
  *  <li>'to' => (int) page number,</li>
  *  <li>'format' => (string) Returns document in the specified format,</li>
  *  <li>'storageName' => (string) Name of the storage,</li>
  *  <li>'folder' => (string) Name of the folder,</li>
  *  <li>'zipOutput' => (bool) save the results as .zip file,</li>
  * </ul>
  *
  * @return string|boolean
  * @throws Exception|InvalidOptionsException
  * @see OptionsResolver
  */
 public function splitDocument(array $options = array())
 {
     $strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/split?';
     $resolver = new OptionsResolver();
     $resolver->setDefined(array('from', 'to', 'format', 'storage', 'folder', 'zipOutput'));
     $options = $resolver->resolve($options);
     $strURI .= http_build_query($options);
     AsposeApp::getLogger()->info('WordsDocument splitDocument call will be made', array('call-uri' => $strURI));
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'POST', '', '');
     $json = json_decode($responseStream);
     if ($json->Code == 200) {
         // Just return the json in case of a zip result
         if (isset($options['zipOutput'])) {
             AsposeApp::getLogger()->info('zipOutput found, so return entire splitResult');
             return $json->SplitResult;
         }
         AsposeApp::getLogger()->info('Separately save each of the split pages');
         $dispatcher = AsposeApp::getEventDispatcher();
         foreach ($json->SplitResult->Pages as $pageNumber => $splitPage) {
             $splitFileName = basename($splitPage->Href);
             //build URI to download split slides
             $strURI = Product::$baseProductUri . '/storage/file/' . $splitFileName;
             //sign URI
             $signedURI = Utils::Sign($strURI);
             $responseStream = Utils::processCommand($signedURI, "GET", "", "");
             //save split slides
             $outputFile = AsposeApp::$outPutLocation . $splitFileName;
             Utils::saveFile($responseStream, $outputFile);
             $event = new SplitPageEvent($outputFile, $pageNumber + 1);
             $dispatcher->dispatch(SplitPageEvent::PAGE_IS_SPLIT, $event);
         }
         return $json->SplitResult->Pages;
     }
     AsposeApp::getLogger()->warning('Error occured, http 200 code was not found.', array('json-code' => $json->Code));
     return false;
 }
 /**
  * Split presentation.
  *
  * @param integer $from The slide number.
  * @param integer $to The slide number.
  * @param string $destination The desitination folder name.
  * @param string $format Return the presentation in the specified format.
  * @param string $storageName The presenatation storage name.
  * @param string $folder The presentation folder name.
  *
  * @return string|boolean
  * @throws Exception
  */
 public function splitPresentation($from = '', $to = '', $destination = '', $format = '', $storageName = '', $folder = '')
 {
     $strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/split?';
     if ($folder != '') {
         $strURI .= '&folder=' . $folder;
     }
     if ($storageName != '') {
         $strURI .= '&storage=' . $storageName;
     }
     if ($from != '') {
         $strURI .= '&from=' . $from;
     }
     if ($to != '') {
         $strURI .= '&to=' . $to;
     }
     if ($destination != '') {
         $strURI .= '&destFolder=' . $destination;
     }
     if ($format != '') {
         $strURI .= '&format=' . $format;
     }
     $strURI = rtrim($strURI, '?');
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'POST', '', '');
     $json = json_decode($responseStream);
     if ($json->Code == 200) {
         foreach ($json->SplitResult->Slides as $splitPage) {
             $splitFileName = basename($splitPage->Href);
             //build URI to download split slides
             $strURI = Product::$baseProductUri . '/storage/file/' . $splitFileName;
             //sign URI
             $signedURI = Utils::Sign($strURI);
             $responseStream = Utils::processCommand($signedURI, "GET", "", "");
             //save split slides
             $outputFile = AsposeApp::$outPutLocation . $splitFileName;
             Utils::saveFile($responseStream, $outputFile);
         }
     } else {
         return false;
     }
 }
 /**
  * Add email attachment.
  *
  * @param string $attachmentName The name of attached file.
  *
  * @return string Return path of the attached file.
  * @throws Exception
  */
 public function addAttachment($attachmentName)
 {
     if ($attachmentName == '') {
         throw new Exception('Attachment Name not specified');
     }
     //build URI
     $strURI = Product::$baseProductUri . '/email/' . $this->getFileName() . '/attachments/' . $attachmentName;
     //sign URI
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'POST', '', '');
     $v_output = Utils::validateOutput($responseStream);
     if ($v_output === '') {
         $strURI = Product::$baseProductUri . '/storage/file/' . $this->getFileName();
         $signedURI = Utils::Sign($strURI);
         $responseStream = Utils::processCommand($signedURI, "GET", "", "");
         $outputPath = AsposeApp::$outPutLocation . $this->getFileName();
         Utils::saveFile($responseStream, $outputPath);
         return $outputPath;
     } else {
         return $v_output;
     }
 }
 /**
  * Convert Excel Workbook with Additional Settings
  * 
  * @param xml $strXML Data in XML format.
  * @param string $outputFile The name of output file.
  * 
  * @return string Returns the file path.
  * @throws Exception
  */
 public function saveAs($strXML, $outputFile)
 {
     if ($strXML == '') {
         throw new Exception('XML Data not specified');
     }
     if ($outputFile == '') {
         throw new Exception('Output Filename along extension not specified');
     }
     $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/saveAs?newfilename=' . $outputFile;
     $signedURI = Utils::Sign($strURI);
     $responseStream = Utils::processCommand($signedURI, "POST", "XML", $strXML);
     $v_output = Utils::validateOutput($responseStream);
     if ($v_output === '') {
         $strURI = Product::$baseProductUri . '/storage/file/' . $outputFile;
         $signedURI = Utils::Sign($strURI);
         $responseStream = Utils::processCommand($signedURI, "GET", "", "");
         $outputPath = AsposeApp::$outPutLocation . $outputFile;
         Utils::saveFile($responseStream, $outputPath);
         return $outputPath;
     } else {
         return $v_output;
     }
 }