try { foreach ($tests as $method => $arg) { $client = new Pdfcrowd($argv[1], $argv[2]); $client->{$method}($arg); $client->setVerticalMargin('1in'); $client->convertFile($test_dir . '/in/simple.html', out_stream(strtolower($method), False)); } } catch (PdfcrowdException $e) { echo "EXCEPTION: " . $e->getMessage(); exit(1); } // margins $client = new Pdfcrowd($argv[1], $argv[2]); $client->setPageMargins('0.25in', '0.5in', '0.75in', '1.0in'); $client->convertHtml('<div style="background-color:red;height:100%">4 margins</div>', out_stream('4margins', False)); // expected failures $failures = array(array("convertHtml", "", "must not be empty"), array("convertFile", "does-not-exist.html", "not found"), array("convertFile", "/", "not a directory"), array("convertFile", $test_dir . "/in/empty.html", "must not be empty"), array("convertURI", "domain.com", "must start with"), array("convertURI", "HtTp://s3.pdfcrowd.com/this/url/does/not/exist/", "Received a non-2xx response")); $client = new Pdfcrowd($argv[1], $argv[2]); $client->setFailOnNon200(True); foreach ($failures as $failure) { try { $client->{$failure}[0]($failure[1]); echo "FAILED expected an exception: {$failure}\n"; exit(1); } catch (PdfcrowdException $e) { if (!strstr($e->getMessage(), $failure[2])) { echo "error message [" . $e->getMessage() . "] is expected to contain [" . $failure[2] . "]\n"; exit(1); } } }