/** * Split an interval of pages in a self definable format * @param int $from * @param int $to * @param string $format * @throws Exception */ public function splitPagesToAnyFormat($from, $to, $format) { try { 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; $resultFiles = array(); $info = pathinfo($this->fileName); 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 = $info['filename'] . "_" . $i . "." . $format; $outputFile = SaasposeApp::$outputLocation . $fileName; Utils::saveFile($responseStream, $outputFile); $resultFiles[$i] = $outputFile; $i++; } return $resultFiles; } catch (Exception $e) { throw new Exception($e->getMessage()); } }