Ejemplo n.º 1
0
 /**
  * Saves a particular slide into various formats with specified width and height
  */
 public function convertToImage($fileName, $saveFormat = 'PPT', $slideNumber, $imageFormat)
 {
     try {
         $strURI = Product::$baseProductUri . "/slides/" . $this->fileName . "/slides/" . $slideNumber . "?format=" . $imageFormat;
         $signedURI = Utils::sign($strURI);
         $responseStream = Utils::processCommand($signedURI, "GET", "", "");
         Utils::saveFile($responseStream, SaasposeApp::$outputLocation . Utils::getFileName($this->fileName) . "." . $this->saveformat);
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
 }
Ejemplo n.º 2
0
 /**
  * Get the particular image from the specified page with the default image size
  * @param int $pageNumber
  * @param int $imageIndex
  * @param string $imageFormat
  * @param int $imageWidth
  * @param int $imageHeight
  */
 public function getImageCustomSize($pageNumber, $imageIndex, $imageFormat, $imageWidth, $imageHeight)
 {
     try {
         $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());
     }
 }
 /**
  * convert a document to SaveFormat
  */
 public function baseConvert($fileType, $fileName, $saveFormat)
 {
     try {
         $strURI = sprintf("%s/%s/%s?format=%s", Product::$baseProductUri, $fileType, $fileName, $saveFormat);
         $signedURI = Utils::sign($strURI);
         $responseStream = Utils::processCommand($signedURI, "GET", "", "");
         $v_output = Utils::validateOutput($responseStream);
         if ($v_output === "") {
             if ($saveFormat == "html") {
                 $saveFormat = "zip";
             }
             $saveFile = SaasposeApp::$outputLocation . Utils::getFileName($fileName) . "." . $saveFormat;
             Utils::saveFile($responseStream, $saveFile);
             return $saveFile;
         } else {
             throw new Exception($v_output);
         }
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
 }
Ejemplo n.º 4
0
 /**
  * convert a document to the given saveFormat
  */
 public function convert($fileName, $saveFormat = 'PPT')
 {
     try {
         //check whether file is set or not
         if ($fileName == "") {
             throw new Exception("No file name specified");
         }
         $strURI = Product::$baseProductUri . "/slides/" . $fileName . "?format=" . $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($fileName) . "." . $saveformat);
             return "";
         } else {
             return $v_output;
         }
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
 }
Ejemplo n.º 5
0
 /**
  * saves a specific auto-shape from a specific sheet as image
  * @param $worksheetName
  * @param $shapeIndex
  * @param $imageFormat
  */
 public function getAutoShape($worksheetName, $shapeIndex, $imageFormat)
 {
     try {
         //Build URI
         $strURI = Product::$baseProductUri . "/cells/" . $this->fileName . "/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 = SaasposeApp::$outputLocation . Utils::getFileName($this->fileName) . "_" . $worksheetName . "." . $imageFormat;
             Utils::saveFile($responseStream, $outputPath);
             return "";
         } else {
             return $v_output;
         }
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
 }
Ejemplo n.º 6
0
 /**
  * Convert Document to different file format without using storage
  * $param string $inputPath
  * @param string $outputPath
  * @param string $outputFormat
  */
 public function convertLocalFile($inputPath = "", $outputPath = "", $outputFormat = "")
 {
     try {
         //check whether file is set or not
         if ($inputPath == "") {
             throw new Exception("No file name specified");
         }
         if ($outputFormat == "") {
             throw new Exception("output format not specified");
         }
         $strURI = Product::$baseProductUri . "/words/convert?format=" . $outputFormat;
         if (!file_exists($inputPath)) {
             throw new Exception("input file doesn't exist.");
         }
         $signedURI = Utils::sign($strURI);
         $responseStream = Utils::uploadFileBinary($signedURI, $inputPath, "xml");
         $v_output = Utils::validateOutput($responseStream);
         if ($v_output === "") {
             if ($outputFormat == "html") {
                 $save_format = "zip";
             } else {
                 $save_format = $outputFormat;
             }
             if ($outputPath == "") {
                 $outputPath = Utils::getFileName($inputPath) . "." . $save_format;
             }
             Utils::saveFile($responseStream, SaasposeApp::$outputLocation . $outputPath);
             return true;
         } else {
             return $v_output;
         }
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
 }
Ejemplo n.º 7
0
 /**
  * Convert drawing object to image
  * @param int $index
  * @param string $renderformat
  */
 public function convertDrawingObject($index, $renderformat)
 {
     try {
         $strURI = Product::$baseProductUri . "/words/" . $this->fileName . "/drawingObjects/" . $index . "?format=" . $renderformat;
         $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) . "_" . $index . "." . $renderformat);
             return "";
         } else {
             return $v_output;
         }
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
 }
Ejemplo n.º 8
0
 /**
  * Saves a particular slide into various formats
  * @param number $slideNumber
  * @param string $outputPath
  * @param string $saveFormat
  */
 public function saveSlideAs($slideNumber = "", $outputPath = "", $saveFormat = "")
 {
     try {
         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->fileName . "/slides/{$slideNumber}?format=" . $saveFormat;
         $signedURI = Utils::sign($strURI);
         $responseStream = Utils::processCommand($signedURI, "GET", "", "");
         $v_output = Utils::validateOutput($responseStream);
         if ($v_output === "") {
             Utils::saveFile($responseStream, $outputPath . Utils::getFileName($this->fileName) . "." . $saveFormat);
             return true;
         } else {
             return $v_output;
         }
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
 }