/** * Read Barcode from Local Image. * * @param string $localImage Path of the local image. * @param string $remoteFolder Name of the remote folder. * @param string $barcodeReadType Type to read barcode. * * @return array * @throws Exception */ public function readFromLocalImage($localImage, $remoteFolder, $barcodeReadType) { $folder = new Folder(); $folder->UploadFile($localImage, $remoteFolder); $data = $this->ReadR(basename($localImage), $remoteFolder, $barcodeReadType); return $data; }
/** * Inserts page number field into the document. * * @param string $fileName Name of the file. * @param string $alignment Alignment of page number. * @param string $format Format for page numbers. * @param boolean $isTop Either True or False. * @param integer $setPageNumberOnFirstPage Set value for first page number. * * @return string Returns the file path. * @throws Exception */ public function insertPageNumber($fileName, $alignment, $format, $isTop, $setPageNumberOnFirstPage) { //check whether files are set or not if ($fileName == '') { throw new Exception('File not specified'); } //Build JSON to post $fieldsArray = array('Format' => $format, 'Alignment' => $alignment, 'IsTop' => $isTop, 'SetPageNumberOnFirstPage' => $setPageNumberOnFirstPage); $json = json_encode($fieldsArray); //build URI to insert page number $strURI = Product::$baseProductUri . '/words/' . $fileName . '/insertPageNumbers'; //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; } }
public function testConvert() { $inputFile = getcwd() . '/Data/Input/test.eml'; $folder = new Folder(); $folder->uploadFile($inputFile, ''); $converter = new Converter('test.eml'); $converter->saveFormat = 'msg'; $converter->convert(); $this->assertFileExists(getcwd() . '/Data/output/test.msg'); }
/** * 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; } }
/** * Update PSD Image Properties without 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 updatePSDPropertiesFromLocalFile($inputPath, $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/psd?channelsCount=' . $channelsCount . '&compression=' . $compression . '&outPath=' . $outPath; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::uploadFileBinary($signedURI, $inputPath, 'xml', 'POST'); $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; } }
/** * 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 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; } }
/** * Deletes all slides from a presentation. * * @param string $storageName The presentation storage name. * @param string $folder The presenation folder name. * * @return string Returns the file path. * @throws Exception */ public function deleteAllSlides($storageName = '', $folder = '') { //Build URI to replace text $strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/slides'; if ($folder != '') { $strURI .= '?folder=' . $folder; } if ($storageName != '') { $strURI .= '&storage=' . $storageName; } $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'DELETE', '', ''); $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; } }
/** * Update chart legend. * * @param integer $chartIndex Index of the chart. * @param array $properties Properties of the chart legend. * * @return string Returns the file path. * @throws Exception */ public function updateChartLegend($chartIndex, $properties = '') { //check whether workshett name is set or not if ($this->worksheetName == '') { throw new Exception('Worksheet name not specified'); } $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/worksheets/' . $this->worksheetName . '/charts/' . $chartIndex . '/legend'; $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'POST', 'json', $properties); $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; } }
public function replaceImageUsingFile($pageNumber, $imageIndex, $fileName) { //check whether files are set or not if ($this->fileName == '') { throw new Exception('PDF file name not specified'); } //build URI to replace image $strURI = Product::$baseProductUri . '/pdf/' . $this->fileName . '/pages/' . $pageNumber . '/images/' . $imageIndex . '?imageFile=' . $fileName; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'POST', '', ''); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { //Save PDF file 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; } }
/** * 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; } }
/** * 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; } }
/** * 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; } }
/** * 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; } }
/** * Appends a list of documents to this one. * * @param string $appendDocs List of documents to append. * @param string $importFormatModes Documents import format modes. * @param string $sourceFolder Name of the folder where documents are present. * * @return string Returns the file path. * @throws Exception */ public function appendDocument($appendDocs, $importFormatModes, $sourceFolder) { //check whether required information is complete if (count($appendDocs) != count($importFormatModes)) { throw new Exception('Please specify complete documents and import format modes'); } $post_array = array(); $i = 0; foreach ($appendDocs as $doc) { $post_array[] = array("Href" => $sourceFolder != "" ? $sourceFolder . "\\" . $doc : $doc, "ImportFormatMode" => $importFormatModes[$i]); $i++; } $data = array("DocumentEntries" => $post_array); $json = json_encode($data); //build URI to merge Docs $strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/appendDocument'; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'POST', 'json', $json); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { //Save merged docs on server $folder = new Folder(); $outputStream = $folder->GetFile($sourceFolder . ($sourceFolder == '' ? '' : '/') . $this->getFileName()); $outputPath = AsposeApp::$outPutLocation . $this->getFileName(); Utils::saveFile($outputStream, $outputPath); return $outputPath; } AsposeApp::getLogger()->warning('Error occured, output could not be validated.', array('v-output' => $v_output)); return $v_output; }