/** * Convert Image Format. * * @param string $inputPath Input file path. * @param string $outputFormat Output file format. * * @return string Returns the file path. * @throws Exception */ public function convertLocalFile($inputPath, $outputFormat) { //check whether files are set or not if ($inputPath == '') { throw new Exception('Input file not specified'); } if ($outputFormat == '') { throw new Exception('Format not specified'); } //build URI $strURI = Product::$baseProductUri . '/imaging/' . $this->getFileName() . '/saveAs?format=' . $outputFormat; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::uploadFileBinary($signedURI, $inputPath, 'xml', 'POST'); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { if ($outputFormat == 'html') { $saveFormat = 'zip'; } else { $saveFormat = $outputFormat; } $outputFilename = Utils::getFileName($inputPath) . '.' . $saveFormat; Utils::saveFile($responseStream, AsposeApp::$outPutLocation . $outputFilename); return $outputFilename; } else { return $v_output; } }
/** * 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; } }
/** * 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 without using Aspose storage. * * @param string $inputPath The path of source file. * @param string $outputPath Path where you want to file after conversion. * @param string $outputFormat New file format. * * @return string Returns the file path. */ public function convertLocalFile($inputPath, $outputPath, $outputFormat) { $str_uri = Product::$baseProductUri . '/words/convert?format=' . $outputFormat; $signed_uri = Utils::sign($str_uri); $responseStream = Utils::uploadFileBinary($signed_uri, $inputPath, 'xml'); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { if ($outputFormat == 'html') { $saveFormat = 'zip'; } else { $saveFormat = $outputFormat; } if ($outputPath == '') { $outputPath = AsposeApp::$outPutLocation . Utils::getFileName($inputPath) . '.' . $saveFormat; } 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; } }
public function saveAs($options_xml = '') { if ($options_xml == '') { throw new Exception('Options not specified.'); } $strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/saveAs'; $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'POST', 'XML', $options_xml, 'json'); $json = json_decode($responseStream); if ($json->Code == 200) { $outputFile = $json->SaveResult->DestDocument->Href; $strURI = Product::$baseProductUri . '/storage/file/' . $outputFile . ''; $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET'); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { $output = AsposeApp::$outPutLocation . $outputFile; Utils::saveFile($responseStream, $output); return $output; } else { return $v_output; } } AsposeApp::getLogger()->warning('Error occured, http 200 code 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; } }
/** * Saves a particular slide into various formats. * * @param integer $slideNumber The slide number. * @param string $outputPath The output directory path. * @param string $saveFormat Return the presentation in the specified format. * * @return string Returns the file path. * @throws Exception */ public function saveSlideAs($slideNumber, $outputPath, $saveFormat) { if ($outputPath == '') { throw new Exception('Output path not specified'); } if ($saveFormat == '') { throw new Exception('Save format not specified'); } if ($slideNumber == '') { throw new Exception('Slide number not specified'); } $strURI = Product::$baseProductUri . '/slides/' . $this->getFileName() . '/slides/' . $slideNumber . '?format=' . $saveFormat; $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { $output = $outputPath . Utils::getFileName($this->getFileName()) . '_' . $slideNumber . '.' . $saveFormat; Utils::saveFile($responseStream, $output); return $output; } 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; } }
/** * 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; } }
/** * 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; } }
/** * Replaces Image in PDF File using Local Image Stream. * * @param integer $pageNumber Number of the page. * @param integer $imageIndex Index of the image. * @param string $fileName The file name. * * @return string Returns the file path. * @throws Exception */ public function replaceImageUsingFile($pageNumber, $imageIndex, $fileName) { //build URI to replace image $strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/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->getFileName()); $outputPath = AsposeApp::$outPutLocation . $this->getFileName(); Utils::saveFile($outputStream, $outputPath); return $outputPath; } else { return $v_output; } }
/** * Download the selected attachment from Pdf document. * * @param string $attachmentIndex Index of the attachment. * * @return string Returns the file path. * @throws Exception */ public function downloadAttachment($attachmentIndex) { $fileInformation = $this->GetAttachment($attachmentIndex); //build URI to download attachment $strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/attachments/' . $attachmentIndex . '/download'; //sign URI $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { Utils::saveFile($responseStream, AsposeApp::$outPutLocation . $fileInformation->Name); return ''; } else { return $v_output; } }
/** * 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; } }
/** * Convert file into specified format without using Aspose cloud storage. * @param string $inputFile Path of the source file. * @param string $outputFile Name of the output file. * @param string $saveFormat Returns document in the specified format. * * @return string Returns the file path. * @throws Exception */ public function convertLocalFile($inputFile, $outputFile, $saveFormat) { if ($inputFile == '') { throw new Exception('Please Specify Input File Name along with path'); } if ($outputFile == '') { throw new Exception('Please Specify Output File Name along with Extension'); } if ($saveFormat == '') { throw new Exception('Please Specify a Save Format'); } $strURI = Product::$baseProductUri . '/cells/convert?format=' . $saveFormat; $signedURI = Utils::sign($strURI); if (!file_exists($inputFile)) { throw new Exception('Input File Doesnt Exists'); } $responseStream = Utils::uploadFileBinary($signedURI, $inputFile, 'xml'); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { if ($saveFormat == 'html') { $outputFormat = 'zip'; } else { $outputFormat = $saveFormat; } if ($outputFile == '') { $outputFileName = Utils::getFileName($inputFile) . '.' . $outputFormat; } else { $outputFileName = Utils::getFileName($outputFile) . '.' . $outputFormat; } Utils::saveFile($responseStream, AsposeApp::$outPutLocation . $outputFileName); return $outputFileName; } 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; } }
/** * 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; } }
/** * 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; } }
public function convertLocalFile($inputFile = '', $outputFilename = '', $outputFormat = '') { //check whether file is set or not if ($inputFile == '') { throw new Exception('No file name specified'); } if ($outputFormat == '') { throw new Exception('output format not specified'); } $strURI = Product::$baseProductUri . '/pdf/convert?format=' . $outputFormat; if (!file_exists($inputFile)) { throw new Exception('input file doesnt exist.'); } $signedURI = Utils::sign($strURI); $responseStream = Utils::uploadFileBinary($signedURI, $inputFile, 'xml'); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { if ($outputFormat == 'html') { $saveFormat = 'zip'; } else { $saveFormat = $outputFormat; } if ($outputFilename == '') { $outputFilename = Utils::getFileName($inputFile) . '.' . $saveFormat; } $outputPath = AsposeApp::$outPutLocation . $outputFilename; Utils::saveFile($responseStream, $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; } }
/** * 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; } }
/** * 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; } }
/** * 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; } }
/** * Get the drawing object from document. * * @param string $objectURI The URI of object. * @param string $outputPath The output directory path. * * @return string|boolean * @throws Exception */ public function getDrawingObject($objectURI, $outputPath) { if ($outputPath == '') { throw new Exception('Output path not specified'); } if ($objectURI == '') { throw new Exception('Object URI not specified'); } $url_arr = explode('/', $objectURI); $objectIndex = end($url_arr); $strURI = $objectURI; $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $json = json_decode($responseStream); if ($json->Code == 200) { if ($json->DrawingObject->ImageDataLink != '') { $strURI = $strURI . '/imageData'; $outputPath = $outputPath . '\\DrawingObject_' . $objectIndex . '.jpeg'; } else { if ($json->DrawingObject->OleDataLink != '') { $strURI = $strURI . '/oleData'; $outputPath = $outputPath . '\\DrawingObject_' . $objectIndex . '.xlsx'; } else { $strURI = $strURI . '?format=jpeg'; $outputPath = $outputPath . '\\DrawingObject_' . $objectIndex . '.jpeg'; } } $signedURI = Utils::sign($strURI); $responseStream = Utils::processCommand($signedURI, 'GET', '', ''); $v_output = Utils::validateOutput($responseStream); if ($v_output === '') { Utils::saveFile($responseStream, $outputPath); return $outputPath; } else { return $v_output; } } else { return false; } }