I am trying to use the PHP example and have gotten it to work with some PDF files, but with other PDF files it returns the error:
Warning: Invalid argument supplied for foreach() in /home/schmitz/public_html/saaspose/index.php on line 66
which is the result of this line:
$responseStream = processCommand($signedURI, “POST”, “”, “”);
returning the following:
“File ‘113.pdf’ is not found.”
I am uncertain as to the exact reason why I am getting these particular errors, however the example pdf file that does work is quite small. The ones that fail are 5MB or larger.
Is there some way I can get better error as to what is happening at your end which might cause the conversion to fail?
thanks,
Scott Schmitz.
<?php require_once('saaspose.php'); //App SID $AppSID = "ebe1b17c-ef0f-40d0-880e-51d9ebe0fda3"; //App Key $AppKey = "7165d4df95c9b6f86c1e3f0d857e3c46"; //Base Product URI $BaseProductUri = "http://api.saaspose.com/v1.0"; if(isset($_REQUEST['AppSID']) == 1 && isset($_REQUEST['AppKey']) == 1) { $AppSID = $_REQUEST['AppSID']; $AppKey = $_REQUEST['AppKey']; } //web server location to save file $OutPutLocation = getcwd() . '/Output/'; $PDFConvertFormat = array( "pdf" => "pdf", "pdfa1a" => "pdfa1a", "pdfa1b" => "pdfa1b", "xps" => "xps", "doc" => "doc", "xml" => "xml", "tiff" => "tiff", "jpeg" => "jpeg", "png" => "png", "emf" => "emf", "bmp" => "bmp", "GIF" => "GIF" ); if(isset($_REQUEST["convert"]) == 1) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . ""; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "/home/schmitz/public_html/saaspose/Temp/" . $_FILES["file"]["name"]); } $file = $_FILES["file"]["name"]; //Upload file to Sasspose server UploadFile(getcwd() . "/Temp/" . $file, "", $BaseProductUri . "/storage/file/"); //build URI to split PDF pages $strURI = $BaseProductUri . "/pdf/" . $file . "/split" . ((isset($_REQUEST["frompage"]) && isset($_REQUEST["topage"])) ? "?from=" . $_REQUEST["frompage"] . "&to=" . $_REQUEST["topage"] . "&format=" . $_REQUEST["OutputFormat"] : "?format=" . $_REQUEST["OutputFormat"]); //sign URI $signedURI = Sign($strURI); $responseStream = processCommand($signedURI, "POST", "", ""); $json = json_decode($responseStream); //iterate throug each document in the result to find output sheets foreach ($json->Result->Documents as $splitPage) { $splitFileName = basename($splitPage->Href); //build URI to download split sheets $strURI = 'http://api.saaspose.com/v1.0/storage/file/' . $splitFileName; //sign URI $signedURI = Sign($strURI); $responseStream = processCommand($signedURI, "GET", "", ""); //save output file $outputFile = $OutPutLocation . $splitFileName; saveFile($responseStream, $outputFile); } } ?>
The easiest way to Create, Convert & Automate Documents in the cloud.
Split PDF Pages to any supported format Using REST:
Please Enter App SID and App Key.
App SID
App Key
Upload File : Convert Format: <?php foreach ($PDFConvertFormat as $value) if ($value == 'png') { echo "$value"; } else { echo "$value"; } ?> From Page No : To Page No :
Submitted from: http://saaspose.com/