Error using the Example

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/

Hi Scott,

You can process up to 1MB files with trial account or up to 'Max File Size' limit if you have a paid plan. If you have signed up for a paid plan and your plan allows less than your required file size, you can use 'Max File Size Limit' option to increase file size limit ($10 for 10MB or $20 for 20MB).

Also, you get proper error messages in response but you need to handle them properly e.g. you can replace "uploadFileBinary($signedURI, $strFile);" with "echo uploadFileBinary($signedURI, $strFile);" in "UploadFile" method of the example to see what happened when you were uploading the file.

"File '113.pdf' is not found." means your file was not uploaded. Please feel free to contact us in case you have further comments or questions.

Best Regards,
Muhammad Ijaz
Support Developer, Saaspose Sialkot Team
http://www.saaspose.com

Thanks! - I upgraded my account last night and was able to get things going.

Scott.