public function DeleteChart($chartIndex) { try { //check whether file is set or not if ($this->FileName == "") { throw new Exception("No file name specified"); } //check whether workshett name is set or not if ($this->WorksheetName == "") { throw new Exception("Worksheet name not specified"); } $strURI = Product::$BaseProductUri . "/cells/" . $this->FileName . "/worksheets/" . $this->WorksheetName . "/charts/" . $chartIndex; $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->FileName); $outputPath = SaasposeApp::$OutPutLocation . $this->FileName; Utils::saveFile($outputStream, $outputPath); return ""; } else { return $v_output; } } catch (Exception $e) { throw new Exception($e->getMessage()); } }
/** * Inserts page number filed into the document. * @param string $fileName * @param string $alignment * @param string $format * @param string $isTop * @param string $setPageNumberOnFirstPage */ public function insertPageNumber($alignment, $format, $isTop, $setPageNumberOnFirstPage) { try { //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 = SaasposeApp::$outputLocation . $fileName; Utils::saveFile($outputStream, $outputPath); return ""; } else { return $v_output; } } catch (Exception $e) { throw new Exception($e->getMessage()); } }
public function Save($codeText, $symbology, $imageFormat, $xResolution, $yResolution, $xDimension, $yDimension) { //build URI to generate barcode $strURI = Product::$BaseProductUri . "/barcode/generate?text=" . $codeText . "&type=" . $symbology . "&format=" . $imageFormat . ($xResolution <= 0 ? "" : "&resolutionX=" . $xResolution) . ($yResolution <= 0 ? "" : "&resolutionY=" . $yResolution) . ($xDimension <= 0 ? "" : "&dimensionX=" . $xDimension) . ($yDimension <= 0 ? "" : "&dimensionY=" . $yDimension); try { //sign URI $signedURI = Utils::Sign($strURI); //get response stream $responseStream = Utils::processCommand($signedURI, "GET", "", ""); //Save output barcode image $outputPath = SaasposeApp::$OutPutLocation . "barcode" . $symbology . "." . $imageFormat; Utils::saveFile($responseStream, $outputPath); return $outputPath; } catch (Exception $e) { throw new Exception($e->getMessage()); } }
public function Convert() { try { //check whether file is set or not if ($this->FileName == "") { throw new Exception("No file name specified"); } $strURI = Product::$BaseProductUri . "/slides/" . $this->FileName . "?format=" . $this->saveformat; $signedURI = Utils::Sign($strURI); $responseStream = Utils::processCommand($signedURI, "GET", "", ""); $v_output = Utils::ValidateOutput($responseStream); if ($v_output === "") { Utils::saveFile($responseStream, SaasposeApp::$OutPutLocation . Utils::getFileName($this->FileName) . "." . $this->saveformat); return ""; } else { return $v_output; } } catch (Exception $e) { throw new Exception($e->getMessage()); } }
public function GetImageCustomSize($pageNumber, $imageIndex, $imageFormat, $imageWidth, $imageHeight) { try { //check whether file is set or not if ($this->FileName == "") { throw new Exception("No file name specified"); } $strURI = Product::$BaseProductUri . "/pdf/" . $this->FileName . "/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 === "") { Utils::saveFile($responseStream, SaasposeApp::$OutPutLocation . Utils::getFileName($this->FileName) . "_" . $imageIndex . "." . $imageFormat); return ""; } else { return $v_output; } } catch (Exception $e) { throw new Exception($e->getMessage()); } }
public function AppendDocument($appendDocs, $importFormatModes, $sourceFolder) { try { //check whether files are set or not if ($this->FileName == "") { throw new Exception("Base file not specified"); } //check whether required information is complete if (count($appendDocs) != count($importFormatModes)) { throw new Exception("Please specify complete documents and import format modes"); } //Build JSON to post $json = '{ "DocumentEntries": ['; for ($i = 0; $i < count($appendDocs); $i++) { $json .= '{ "Href": "' . $sourceFolder . $appendDocs[$i] . '", "ImportFormatMode": "' . $importFormatModes[$i] . '" }' . ($i < count($appendDocs) - 1 ? ',' : ''); } $json .= ' ] }'; //build URI to merge Docs $strURI = Product::$BaseProductUri . "/words/" . $this->FileName . "/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->FileName); $outputPath = SaasposeApp::$OutPutLocation . $this->FileName; Utils::saveFile($outputStream, $outputPath); return ""; } else { return $v_output; } } catch (Exception $e) { throw new Exception($e->getMessage()); } }
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"); } } try { //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 . "/slides/" . $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 = SaasposeApp::$OutPutLocation . $this->FileName; Utils::saveFile($outputStream, $outputPath); return ""; } else { return $v_output; } } catch (Exception $e) { throw new Exception($e->getMessage()); } }
public function AutoShapeToImage($shapeIndex, $imageFormat) { try { //check whether file and sheet is set or not if ($this->FileName == "") { throw new Exception("No file name specified"); } if ($this->WorksheetName == "") { throw new Exception("No worksheet specified"); } //Build URI $strURI = Product::$BaseProductUri . "/cells/" . $this->FileName . "/worksheets/" . $this->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 = SaasposeApp::$OutPutLocation . Utils::getFileName($this->FileName) . "_" . $this->WorksheetName . "." . $imageFormat; Utils::saveFile($responseStream, $outputPath); return $outputPath; } else { return $v_output; } } catch (Exception $e) { throw new Exception($e->getMessage()); } }
public function DownloadAttachment($attachmentIndex) { try { //check whether files are set or not if ($this->FileName == "") { throw new Exception("PDF file name not specified"); } $fileInformation = $this->GetAttachment($attachmentIndex); //build URI to download attachment $strURI = Product::$BaseProductUri . "/pdf/" . $this->FileName . "/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, SaasposeApp::$OutPutLocation . $fileInformation->Name); return ""; } else { return $v_output; } } catch (Exception $e) { throw new Exception($e->getMessage()); } }
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[1]; $newText = $parameters[2]; $worksheetName = $parameters[0]; } else { throw new Exception("Invalid number of arguments"); } } try { //check whether file is set or not if ($this->FileName == "") { throw new Exception("No file name specified"); } //Build URI to replace text $strURI = Product::$BaseProductUri . "/cells/" . $this->FileName . (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->FileName); $outputPath = SaasposeApp::$OutPutLocation . $this->FileName; Utils::saveFile($outputStream, $outputPath); return ""; } else { return $v_output; } } catch (Exception $e) { throw new Exception($e->getMessage()); } }
public function ReplaceImageUsingFile($pageNumber, $imageIndex, $fileName) { try { //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 = SaasposeApp::$OutPutLocation . $this->FileName; Utils::saveFile($outputStream, $outputPath); return ""; } else { return $v_output; } } catch (Exception $e) { throw new Exception($e->getMessage()); } }
public function ReplaceText($fileName, $oldValue, $newValue, $isMatchCase, $isMatchWholeWord) { try { //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 = SaasposeApp::$OutPutLocation . $fileName; Utils::saveFile($outputStream, $outputPath); return ""; } else { return $v_output; } } catch (Exception $e) { throw new Exception($e->getMessage()); } }
public function ExecuteTemplate($fileName, $strXML) { try { //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"; //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($json->Document->FileName); $outputPath = SaasposeApp::$OutPutLocation . $fileName; Utils::saveFile($outputStream, $outputPath); return ""; } else { return $v_output; } } catch (Exception $e) { throw new Exception($e->getMessage()); } }