/**
  * Generates new barcodes with specific text, symbology, image format,
  * resolution and dimensions.
  *
  * @param string $codeText Text to encode inside barcode.
  * @param string $symbology Type of barcode.
  * @param string $imageFormat Returns an image in the specified format.
  * @param float $xResolution Resolution along X in dpi.
  * @param float $yResolution Resolution along Y in dpi.
  * @param float $xDimension Width of barcode unit (bar or space).
  * @param float $yDimension Height of barcode unit (for 2D barcodes).
  *
  * @return string Returns the file path.
  * @throws Exception
  */
 public function save($codeText, $symbology, $imageFormat = 'png', $xResolution = 0, $yResolution = 0, $xDimension = 0, $yDimension = 0, $codeLocation = null, $folder = null, $storage = null, $name = null, $grUnit = null, $autoSize = null, $barHeight = 0, $imageHeight = 0, $imageWidth = 0, $imageQuality = null, $rotAngle = 0, $topMargin = 0, $bottomMargin = 0, $leftMargin = 0, $rightMargin = 0, $enableChecksum = null)
 {
     //build URI to generate barcode
     $strURI = Product::$baseProductUri . '/barcode' . (strlen($name) <= 0 ? '' : '/' . $name) . '/generate?text=' . $codeText . '&type=' . $symbology . '&format=' . $imageFormat . ($xResolution <= 0 ? '' : '&resolutionX=' . $xResolution) . ($yResolution <= 0 ? '' : '&resolutionY=' . $yResolution) . ($xDimension <= 0 ? '' : '&dimensionX=' . $xDimension) . ($yDimension <= 0 ? '' : '&dimensionY=' . $yDimension) . (strlen($codeLocation) <= 0 ? '' : '&codeLocation=' . $codeLocation) . (strlen($grUnit) <= 0 ? '' : '&grUnit=' . $grUnit) . (strlen($autoSize) <= 0 ? '' : '&autoSize=' . $autoSize) . ($barHeight <= 0 ? '' : '&barHeight=' . $barHeight) . ($imageHeight <= 0 ? '' : '&imageHeight=' . $imageHeight) . ($imageWidth <= 0 ? '' : '&imageWidth=' . $imageWidth) . (strlen($imageQuality) <= 0 ? '' : '&imageQuality=' . $imageQuality) . ($rotAngle <= 0 ? '' : '&rotAngle=' . $rotAngle) . ($topMargin <= 0 ? '' : '&topMargin=' . $topMargin) . ($bottomMargin <= 0 ? '' : '&bottomMargin=' . $bottomMargin) . ($leftMargin <= 0 ? '' : '&leftMargin=' . $leftMargin) . ($rightMargin <= 0 ? '' : '&rightMargin=' . $rightMargin) . (strlen($folder) <= 0 ? '' : '&folder=' . $folder) . (strlen($storage) <= 0 ? '' : '&storage=' . $storage) . (strlen($enableChecksum) <= 0 ? '' : '&enableChecksum=' . $enableChecksum);
     if (strlen($codeLocation) <= 0 and strlen($grUnit) <= 0 and strlen($autoSize) <= 0 and $barHeight <= 0 and $imageHeight <= 0 and $imageWidth <= 0 and strlen($imageQuality) <= 0 and $rotAngle <= 0 and $topMargin <= 0 and $bottomMargin <= 0 and $leftMargin <= 0 and $rightMargin <= 0 and strlen($folder) <= 0 and strlen($storage) <= 0 and strlen($name) <= 0 and strlen($enableChecksum) <= 0) {
         //sign URI
         $signedURI = Utils::sign($strURI);
         //get response stream
         $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
         //Save output barcode image
         $outputPath = AsposeApp::$outPutLocation . 'barcode' . $symbology . '.' . $imageFormat;
         Utils::saveFile($responseStream, $outputPath);
         return $outputPath;
     } else {
         //sign URI
         $signedURI = Utils::sign($strURI);
         //get response stream
         $responseStream = Utils::processCommand($signedURI, 'PUT', '', '');
         //build URI to execute mail merge
         $strURI = 'http://api.aspose.com/v1.0/storage/file/' . $name;
         //sign URI
         $signedURI = Utils::sign($strURI);
         //get response stream
         $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
         //Save output barcode image
         $outputPath = AsposeApp::$outPutLocation . 'barcode' . $symbology . '.' . $imageFormat;
         Utils::saveFile($responseStream, $outputPath);
         return $outputPath;
     }
 }
 /**
  * Gets all merge filed names from document.
  *
  * @param string $fileName The name of source file.
  *
  * @return array
  * @throws Exception
  */
 public function getMailMergeFieldNames($fileName)
 {
     //check whether file is set or not
     if ($fileName == '') {
         throw new Exception('No file name specified');
     }
     $strURI = Product::$baseProductUri . '/words/' . $fileName . '/mailMergeFieldNames';
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
     $json = json_decode($responseStream);
     return $json->FieldNames->Names;
 }
 /**
  * Get the particular image from the specified page with the default image size.
  *
  * @param int $pageNumber Number of the page.
  * @param int $imageIndex Index of the page.
  * @param string $imageFormat Returns image in the specified format.
  * @param int $imageWidth Width of the image.
  * @param int $imageHeight Height of the image.
  *
  * @return string Returns the file path.
  * @throws Exception
  */
 public function getImageCustomSize($pageNumber, $imageIndex, $imageFormat, $imageWidth, $imageHeight)
 {
     $strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/pages/' . $pageNumber . '/images/' . $imageIndex . '?format=' . $imageFormat . '&width=' . $imageWidth . '&height=' . $imageHeight;
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
     $v_output = Utils::validateOutput($responseStream);
     if ($v_output === '') {
         $outputPath = AsposeApp::$outPutLocation . Utils::getFileName($this->getFileName()) . '_' . $imageIndex . '.' . $imageFormat;
         Utils::saveFile($responseStream, $outputPath);
         return $outputPath;
     } else {
         return $v_output;
     }
 }
 /**
  * Convert a document to SaveFormat using Aspose storage.
  *
  * @return string Returns the file path.
  * @throws Exception
  */
 public function convert()
 {
     //build URI
     $strURI = Product::$baseProductUri . '/tasks/' . $this->getFileName() . '?format=' . $this->saveFormat;
     //sign URI
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
     $v_output = Utils::validateOutput($responseStream);
     if ($v_output === '') {
         if ($this->saveFormat == 'html') {
             $save_format = 'zip';
         } else {
             $save_format = $this->saveFormat;
         }
         $outputPath = AsposeApp::$outPutLocation . Utils::getFileName($this->getFileName()) . '.' . $save_format;
         Utils::saveFile($responseStream, $outputPath);
         return $outputPath;
     } else {
         return $v_output;
     }
 }
 /**
  * Copies a file in Aspose storage to a new destination
  *
  * @param string $fileName The name of file.
  * @param string $storageName The name of storage.
  * @return bool
  * @throws Exception
  */
 public function copyFile($fileName, $storageName = '', $newDest)
 {
     //check whether file is set or not
     if ($fileName == '' || $newDest == '') {
         AsposeApp::getLogger()->error(Exception::MSG_NO_FILENAME);
         throw new Exception(Exception::MSG_NO_FILENAME);
     }
     //build URI
     $strURI = $this->strURIFile . $fileName . '?newdest=' . $newDest;
     if ($storageName != '') {
         $strURI .= '&storage=' . $storageName;
     }
     //sign URI
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'PUT', '', '');
     $json = json_decode($responseStream);
     if ($json->Code === 200) {
         return true;
     }
     return false;
 }
 /**
  * Deletes a project assignment with all references to it.
  *
  * @param integer $assignmentUid The uid of assignment.
  * @param string $changedFileName The name of the project document to save changes to. If this parameter is omitted then the changes will be saved to the source project document.
  *
  * @return string Returns the assignment path.
  * @throws Exception
  */
 public function deleteAssignment($assignmentUid, $changedFileName)
 {
     if ($assignmentUid == '') {
         throw new Exception('Assignment Uid not specified');
     }
     //build URI
     $strURI = Product::$baseProductUri . '/tasks/' . $this->getFileName() . '/assignments/' . $assignmentUid;
     if ($changedFileName != '') {
         $strURI .= '?fileName=' . $changedFileName;
         $this->setFileName($changedFileName);
     }
     //sign URI
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'DELETE', '', '');
     $v_output = Utils::validateOutput($responseStream);
     if ($v_output === '') {
         $folder = new Folder();
         $outputStream = $folder->GetFile($this->getFileName());
         $outputPath = AsposeApp::$outPutLocation . $this->getFileName();
         Utils::saveFile($outputStream, $outputPath);
         return $outputPath;
     } else {
         return $v_output;
     }
 }
 /**
  * Sign PDF Documents
  *
  * @param int|string $pageNumber Number of the page.
  * @param json $postData Data should be in JSON format.
  * @return bool|string
  * @throws Exception
  */
 public function addSignature($pageNumber = '', $postData)
 {
     if ($postData == '') {
         throw new Exception('Data not provided');
     }
     $strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName();
     if ($pageNumber) {
         $strURI .= '/pages/' . $pageNumber;
     }
     $strURI .= '/sign';
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'POST', 'JSON', $postData);
     $json = json_decode($responseStream);
     if ($json->Code == 200) {
         $folder = new Folder();
         $outputStream = $folder->GetFile($this->getFileName());
         $outputPath = AsposeApp::$outPutLocation . $this->getFileName();
         Utils::saveFile($outputStream, $outputPath);
         return $outputPath;
     } else {
         return false;
     }
 }
 /**
  * Update PSD Image Properties on Aspose cloud storage.
  *
  * @param integer $channelsCount Count of channels.
  * @param string $compression Compression method.
  * @param string $outPath Name of the output file.
  *
  * @return string Returns the file path.
  * @throws Exception
  */
 public function updatePSDProperties($channelsCount, $compression, $outPath)
 {
     if ($channelsCount == '') {
         throw new Exception('Channels count not specified');
     }
     if ($compression == '') {
         throw new Exception('Compression method not specified');
     }
     if ($outPath == '') {
         throw new Exception('Output file name not specified');
     }
     //build URI
     $strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/psd?channelsCount=' . $channelsCount . '&compression=' . $compression . '&outPath=' . $outPath;
     //sign URI
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
     $v_output = Utils::validateOutput($responseStream);
     if ($v_output === '') {
         $folder = new Folder();
         $outputStream = $folder->GetFile($outPath);
         $outputPath = AsposeApp::$outPutLocation . $outPath;
         Utils::saveFile($outputStream, $outputPath);
         return $outputPath;
     } else {
         return $v_output;
     }
 }
 public function getFilesList($strFolder, $storageName = '')
 {
     //build URI
     $strURI = $this->strURIFolder;
     //check whether file is set or not
     if (!$strFolder == '') {
         $strURI .= $strFolder;
     }
     if ($storageName != '') {
         $strURI .= '?storage=' . $storageName;
     }
     //sign URI
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
     $json = json_decode($responseStream);
     return $json->Files;
 }
 /**
  * Get Aspect Ratio of a PowerPoint Slide
  * 
  * @param type $slideNumber The number of slide.
  * 
  * @return float|boolean
  * @throws Exception
  */
 public function aspectRatio($slideNumber)
 {
     if ($slideNumber == '') {
         throw new Exception('Slide number not specified');
     }
     //build URI
     $strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/slides/' . $slideNumber;
     //sign URI
     $signedURI = Utils::sign($strURI);
     $response = Utils::processCommand($signedURI, 'GET', '', '');
     $json = json_decode($response);
     if ($json->Code == 200) {
         return $json->Slide->Width / $json->Slide->Height;
     } else {
         return false;
     }
 }
 /**
  * Convert PowerPoint Documents to other File Formats with Additional Settings
  * 
  * @param type $saveFormat Return the presentation in the specified format. 
  * @param type $textCompression Specifies compression type to be used for all textual content in the document. 
  * @param type $embedFullFonts Determines if all characters of font should be embedded or only used subset. 
  * @param type $compliance Desired conformance level for generated PDF document.
  * @param type $jpegQuality Value determining the quality of the JPEG images inside PDF document. 
  * @param type $saveMetafilesAsPng True to convert all metafiles used in a presentation to the PNG images. 
  * @param type $pdfPassword Setting user password to protect the PDF document. 
  * @param type $embedTrueTypeFontsForASCII Determines service will embed common fonts for ASCII.
  * 
  * @return string Returns the file path.
  */
 public function convertWithAdditionalSettings($saveFormat = 'pdf', $textCompression = '', $embedFullFonts = '', $compliance = '', $jpegQuality = '', $saveMetafilesAsPng = '', $pdfPassword = '', $embedTrueTypeFontsForASCII = '')
 {
     $strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '?format=' . $saveFormat;
     if ($textCompression != '') {
         $strURI .= '&TextCompression=' . $textCompression;
     }
     if ($embedFullFonts != '') {
         $strURI .= '&EmbedFullFonts=' . $embedFullFonts;
     }
     if ($compliance != '') {
         $strURI .= '&Compliance=' . $compliance;
     }
     if ($jpegQuality != '') {
         $strURI .= '&JpegQuality=' . $jpegQuality;
     }
     if ($saveMetafilesAsPng != '') {
         $strURI .= '&SaveMetafilesAsPng=' . $saveMetafilesAsPng;
     }
     if ($pdfPassword != '') {
         $strURI .= '&PdfPassword='******'') {
         $strURI .= '&EmbedTrueTypeFontsForASCII=' . $embedTrueTypeFontsForASCII;
     }
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
     $v_output = Utils::validateOutput($responseStream);
     if ($v_output === '') {
         $outputPath = AsposeApp::$outPutLocation . Utils::getFileName($this->getFileName()) . '.' . $saveFormat;
         Utils::saveFile($responseStream, $outputPath);
         return $outputPath;
     } else {
         return $v_output;
     }
 }
 /**
  * Manipulate a Frame and Save the Modified Frame Along with Unmodified Frames.
  *
  * @param integer $frameId Number of frame.
  * @param string $rotateFlipMethod RotateFlip method.
  * @param integer $newWidth New width of the scaled image.
  * @param integer $newHeight New height of the scaled image.
  * @param integer $x X position of start point for cropping rectangle.
  * @param integer $y Y position of start point for cropping rectangle.
  * @param integer $rectWidth Width of cropping rectangle.
  * @param integer $rectHeight Height of cropping rectangle.
  * @param string $outPath Path to updated file.
  *
  * @return string Returns the file path.
  * @throws Exception
  */
 public function manipulateFrame($frameId, $rotateFlipMethod, $newWidth, $newHeight, $x, $y, $rectWidth, $rectHeight, $outPath)
 {
     if ($frameId == '') {
         throw new Exception('Frame ID not specified');
     }
     if ($rotateFlipMethod == '') {
         throw new Exception('RotateFlip method not specified');
     }
     if ($newWidth == '') {
         throw new Exception('New width not specified');
     }
     if ($newHeight == '') {
         throw new Exception('New height not specified');
     }
     if ($x == '') {
         throw new Exception('X position not specified');
     }
     if ($y == '') {
         throw new Exception('Y position not specified');
     }
     if ($rectWidth == '') {
         throw new Exception('Width of cropping rectangle not specified');
     }
     if ($rectHeight == '') {
         throw new Exception('Height of cropping rectangle not specified');
     }
     if ($outPath == '') {
         throw new Exception('Output file not specified');
     }
     //build URI
     $strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/frames/' . $frameId . '?saveOtherFrames=false&rotateFlipMethod=' . $rotateFlipMethod . '&newWidth=' . $newWidth . '&newHeight=' . $newHeight . '&x=' . $x . '&y=' . $y . '&rectWidth=' . $rectWidth . '&rectHeight=' . $rectHeight . '&outPath=' . $outPath;
     //sign URI
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
     $v_output = Utils::validateOutput($responseStream);
     if ($v_output === '') {
         $folder = new Folder();
         $outputStream = $folder->GetFile($outPath);
         $outputPath = AsposeApp::$outPutLocation . $outPath;
         Utils::saveFile($outputStream, $outputPath);
         return $outputPath;
     } else {
         return $v_output;
     }
 }
 public function replaceText()
 {
     $parameters = func_get_args();
     //set parameter values
     if (count($parameters) == 3) {
         $oldText = $parameters[0];
         $newText = $parameters[1];
         $isRegularExpression = $parameters[2];
     } else {
         if (count($parameters) == 4) {
             $oldText = $parameters[0];
             $newText = $parameters[1];
             $isRegularExpression = $parameters[2];
             $pageNumber = $parameters[3];
         } else {
             throw new Exception('Invalid number of arguments');
         }
     }
     //check whether file is set or not
     if ($this->fileName == '') {
         throw new Exception('No file name specified');
     }
     //Build JSON to post
     $fieldsArray = array('OldValue' => $oldText, 'NewValue' => $newText, 'Regex' => $isRegularExpression);
     $json = json_encode($fieldsArray);
     //Build URI to replace text
     $strURI = Product::$baseProductUri . '/pdf/' . $this->fileName . (isset($parameters[3]) ? '/pages/' . $pageNumber : '') . '/replaceText';
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'POST', 'json', $json);
     $v_output = Utils::validateOutput($responseStream);
     if ($v_output === '') {
         //Save doc on server
         $folder = new Folder();
         $outputStream = $folder->GetFile($this->fileName);
         $outputPath = AsposeApp::$outPutLocation . $this->fileName;
         Utils::saveFile($outputStream, $outputPath);
         return $outputPath;
     } else {
         return $v_output;
     }
 }
 /**
  * Get the Current Protection of the Word
  * 
  * @return string|boolean
  */
 public function getProtection()
 {
     $strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/protection';
     $signedURI = Utils::sign($strURI);
     $response = Utils::processCommand($signedURI, 'GET', '', '');
     $json = json_decode($response);
     if ($json->Code == 200) {
         return $json->ProtectionData->ProtectionType;
     } else {
         return false;
     }
 }
 /**
  * Replaces all instances of old text with new text in the Excel document or a particular worksheet.
  * @param string $oldText The old text.
  * @param string $newText The new text.
  *
  * @return string Returns the file path.
  * @throws Exception
  */
 public function replaceText()
 {
     $parameters = func_get_args();
     //set parameter values
     if (count($parameters) == 2) {
         $oldText = $parameters[0];
         $newText = $parameters[1];
     } else {
         if (count($parameters) == 3) {
             $oldText = $parameters[0];
             $newText = $parameters[1];
             $worksheetName = $parameters[2];
         } else {
             throw new Exception('Invalid number of arguments');
         }
     }
     //Build URI to replace text
     $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . (count($parameters) == 3 ? '/worksheets/' . $worksheetName : '') . '/replaceText?oldValue=' . $oldText . '&newValue=' . $newText;
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'POST', '', '');
     $v_output = Utils::validateOutput($responseStream);
     if ($v_output === '') {
         //Save doc on server
         $folder = new Folder();
         $outputStream = $folder->GetFile($this->getFileName());
         $outputPath = AsposeApp::$outPutLocation . $this->getFileName();
         Utils::saveFile($outputStream, $outputPath);
         return $outputPath;
     } else {
         return $v_output;
     }
 }
 /**
  * Replace a text with the new value in the document.
  *
  * @param string $fileName The source file path.
  * @param string $oldValue The old text.
  * @param string $newValue The new text that replace old text.
  * @param string $isMatchCase Either True or False.
  * @param string $isMatchWholeWord Either True or False.
  *
  * @return string Returns the file path.
  * @throws Exception
  */
 public function replaceText($fileName, $oldValue, $newValue, $isMatchCase, $isMatchWholeWord)
 {
     //check whether files are set or not
     if ($fileName == '') {
         throw new Exception('File not specified');
     }
     //Build JSON to post
     $fieldsArray = array('OldValue' => $oldValue, 'NewValue' => $newValue, 'IsMatchCase' => $isMatchCase, 'IsMatchWholeWord' => $isMatchWholeWord);
     $json = json_encode($fieldsArray);
     //build URI to replace text
     $strURI = Product::$baseProductUri . '/words/' . $fileName . '/replaceText';
     //sign URI
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'POST', 'json', $json);
     $v_output = Utils::validateOutput($responseStream);
     if ($v_output === '') {
         //Save docs on server
         $folder = new Folder();
         $outputStream = $folder->GetFile($fileName);
         $outputPath = AsposeApp::$outPutLocation . $fileName;
         Utils::saveFile($outputStream, $outputPath);
         return $outputPath;
     } else {
         return $v_output;
     }
 }
 /**
  * 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;
     }
 }
 /**
  * Delete Chart Title in Excel Worksheet
  *
  * @param integer $chartIndex Index of the chart.
  *
  * @return boolean
  * @throws Exception
  */
 public function deleteChartTitle($chartIndex)
 {
     //check whether workshett name is set or not
     if ($this->worksheetName == '') {
         throw new Exception('Worksheet name not specified');
     }
     if (!isset($chartIndex)) {
         throw new Exception('Chart Index not specified');
     }
     $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $this->worksheetName . '/charts/' . $chartIndex . '/title';
     $signedURI = Utils::sign($strURI);
     $response = Utils::processCommand($signedURI, 'DELETE', '', '');
     $json = json_decode($response);
     if ($json->Code == 200) {
         return true;
     } else {
         return false;
     }
 }
 /**
  * Perform Several Operations on Image
  * 
  * @param string $rotateFlipMethod RotateFlip method.
  * @param integer $newWidth New width of the scaled image.
  * @param integer $newHeight New height of the scaled image.
  * @param integer $xPosition X position of start point for cropping rectangle.
  * @param integer $yPosition Y position of start point for cropping rectangle.
  * @param integer $rectWidth Width of cropping rectangle.
  * @param integer $rectHeight Height of cropping rectangle.
  * @param string $saveFormat Save image in another format.
  * @param string $outPath Path to updated file.
  * 
  * @return boolean|string
  * @throws Exception
  */
 public function updateImage($rotateFlipMethod, $newWidth, $newHeight, $xPosition, $yPosition, $rectWidth, $rectHeight, $saveFormat, $outPath)
 {
     if ($rotateFlipMethod == '') {
         throw new Exception('Rotate Flip Method not specified');
     }
     if ($newWidth == '') {
         throw new Exception('New width not specified');
     }
     if ($newHeight == '') {
         throw new Exception('New Height not specified');
     }
     if ($xPosition == '') {
         throw new Exception('X position not specified');
     }
     if ($yPosition == '') {
         throw new Exception('Y position not specified');
     }
     if ($rectWidth == '') {
         throw new Exception('Rectangle width not specified');
     }
     if ($rectHeight == '') {
         throw new Exception('Rectangle Height not specified');
     }
     if ($saveFormat == '') {
         throw new Exception('Format not specified');
     }
     if ($outPath == '') {
         throw new Exception('Output file name not specified');
     }
     //build URI
     $strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/updateimage?rotateFlipMethod=' . $rotateFlipMethod . '&newWidth=' . $newWidth . '&newHeight=' . $newHeight . '&x=' . $xPosition . '&y=' . $yPosition . '&rectWidth=' . $rectWidth . '&rectHeight=' . $rectHeight . '&format=' . $saveFormat . '&outPath=' . $outPath;
     //sign URI
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
     //$json = json_decode($response);
     $v_output = Utils::validateOutput($responseStream);
     if ($v_output === '') {
         $outputPath = AsposeApp::$outPutLocation . $this->getFileName();
         Utils::saveFile($responseStream, $outputPath);
         return $outputPath;
     } else {
         return false;
     }
 }
 /**
  * Executes mail merge template.
  *
  * @param string $fileName The name of source file.
  * @param string $strXML Data in xml format.
  * @param string $documentFolder The document folder.
  *
  * @return string Returns the file path.
  * @throws Exception
  */
 public function executeTemplate($fileName, $strXML, $documentFolder = '')
 {
     //check whether files are set or not
     if ($fileName == '') {
         throw new Exception('File not specified');
     }
     //build URI to execute mail merge template
     $strURI = Product::$baseProductUri . '/words/' . $fileName . '/executeTemplate' . ($documentFolder == '' ? '' : '?folder=' . $documentFolder);
     //sign URI
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'POST', '', $strXML);
     $v_output = Utils::validateOutput($responseStream);
     if ($v_output === '') {
         $json = json_decode($responseStream);
         //Save docs on server
         $folder = new Folder();
         $outputStream = $folder->GetFile($documentFolder == '' ? $json->Document->FileName : $documentFolder . '/' . $json->Document->FileName);
         $outputPath = AsposeApp::$outPutLocation . $fileName;
         Utils::saveFile($outputStream, $outputPath);
         return $outputPath;
     } else {
         return $v_output;
     }
 }
 /**
  * Gets a specfied link on a specified document page
  *
  * @param integer $pageNumber Number of the page.
  * @param integer $linkIndex Index of the link.
  *
  * @return object
  * @throws Exception
  */
 public function getLink($pageNumber, $linkIndex)
 {
     $strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/pages/' . $pageNumber . '/links/' . $linkIndex;
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
     $json = json_decode($responseStream);
     return $json->Link;
 }
 /**
  * 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;
 }
 /**
  * Extract OCR or HOCR Text from image url.
  *
  * @param string $url URL of the image.
  * @param string $language Language of document to recogniize.
  * @param string $useDefaultDictionaries Allows to correct text after
  * recognition using default dictionaries.
  *
  * @return object
  */
 public function extractTextFromUrl($url, $language, $useDefaultDictionaries)
 {
     $strURI = Product::$baseProductUri . '/ocr/recognize?url=' . $url . '&language=' . $language . '&useDefaultDictionaries=' . $useDefaultDictionaries;
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI);
     $json = json_decode($responseStream);
     return $json;
 }
 public function convert()
 {
     //check whether file is set or not
     if ($this->fileName == '') {
         throw new Exception('No file name specified');
     }
     $strURI = Product::$baseProductUri . '/pdf/' . $this->fileName . '?format=' . $this->saveFormat;
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
     $v_output = Utils::validateOutput($responseStream);
     if ($v_output === '') {
         if ($this->saveFormat == 'html') {
             $saveFormat = 'zip';
         } else {
             $saveFormat = $this->saveFormat;
         }
         $outputPath = Utils::saveFile($responseStream, AsposeApp::$outPutLocation . Utils::getFileName($this->fileName) . '.' . $saveFormat);
         return $outputPath;
     } else {
         return $v_output;
     }
 }
 /**
  * Update Bookmark Text of a Word
  * 
  * @return boolean
  * @throws Exception
  */
 public function updateBookmark($bookmarkName, $bookmarkText)
 {
     if ($bookmarkName == '') {
         throw new Exception('Bookmark name not specified');
     }
     if ($bookmarkText == '') {
         throw new Exception('Bookmark text not specified');
     }
     //build URI
     $strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/bookmarks/' . $bookmarkName;
     //sign URI
     $signedURI = Utils::sign($strURI);
     $post_data_arr['Text'] = $bookmarkText;
     $postData = json_encode($post_data_arr);
     $responseStream = Utils::processCommand($signedURI, 'POST', 'JSON', $postData);
     $json = json_decode($responseStream);
     if ($json->Code == 200) {
         return true;
     }
     AsposeApp::getLogger()->warning('Error occured, http 200 code was not found.', array('json-code' => $json->Code));
     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;
     }
 }
 public function splitPagesToAnyFormat($from, $to, $format)
 {
     if ($this->fileName == '') {
         throw new Exception('File name not specified');
     }
     $strURI = Product::$baseProductUri . '/pdf/' . $this->fileName . '/split?from=' . $from . '&to=' . $to . '&format=' . $format;
     $signedURI = Utils::sign($strURI);
     $responseStream = Utils::processCommand($signedURI, 'POST', '', '');
     $json = json_decode($responseStream);
     $i = 1;
     foreach ($json->Result->Documents as $splitPage) {
         $splitFileName = basename($splitPage->Href);
         $strURI = Product::$baseProductUri . '/storage/file/' . $splitFileName;
         $signedURI = Utils::sign($strURI);
         $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
         $fileName = $this->fileName . '_' . $i . '.' . $format;
         $outputFile = AsposeApp::$outPutLocation . $fileName;
         Utils::saveFile($responseStream, $outputFile);
         echo $outputFile . '<br />';
         $i++;
     }
 }
 /**
  * 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;
     }
 }
 /**
  * Saves a specific auto-shape from a specific sheet as image.
  *
  * @param string $worksheetName Name of the sheet.
  * @param integer $shapeIndex Index of the shape.
  * @param string $imageFormat Returns image in the specified format.
  *
  * @return string Returns the file path.
  * @throws Exception
  */
 public function getAutoShape($worksheetName, $shapeIndex, $imageFormat)
 {
     //Build URI
     $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $worksheetName . '/autoshapes/' . $shapeIndex . '?format=' . $imageFormat;
     //Sign URI
     $signedURI = Utils::sign($strURI);
     //Send request and receive response stream
     $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
     //Validate output
     $v_output = Utils::validateOutput($responseStream);
     if ($v_output === '') {
         //Save ouput file
         $outputPath = AsposeApp::$outPutLocation . Utils::getFileName($this->getFileName()) . '_' . $worksheetName . '.' . $imageFormat;
         Utils::saveFile($responseStream, $outputPath);
         return $outputPath;
     } else {
         return $v_output;
     }
 }