chdir(dirname($argv[0])); $test_dir = './test_files'; function out_stream($name, $use_ssl) { $fname = "./test_files/out/php_client_{$name}"; if ($use_ssl) { $fname .= "_ssl"; } return fopen($fname . '.pdf', 'wb'); } $html = "<html><body>Uploaded content!</body></html>"; $client = new Pdfcrowd($argv[1], $argv[2]); foreach (array(False, True) as $i => $use_ssl) { $client->useSSL($use_ssl); try { $ntokens = $client->numTokens(); $client->convertURI('http://dl.dropboxusercontent.com/u/9346438/tests/webtopdfcom.html', out_stream('uri', $use_ssl)); $client->convertHtml($html, out_stream('content', $use_ssl)); $client->convertFile($test_dir . '/in/simple.html', out_stream('upload', $use_ssl)); $client->convertFile($test_dir . '/in/archive.tar.gz', out_stream('archive', $use_ssl)); $after_tokens = $client->numTokens(); echo "remaining tokens: {$after_tokens}\n"; if ($ntokens - 4 != $after_tokens) { throw new Exception("Mismatch in the number of tokens."); } } catch (PdfcrowdException $e) { echo "EXCEPTION: " . $e->getMessage(); exit(1); } } $tests = array('setPageWidth' => 500, 'setPageHeight' => -1, 'setHorizontalMargin' => 0, 'setVerticalMargin' => 72, 'setEncrypted' => True, 'setUserPassword' => 'userpwd', 'setOwnerPassword' => 'ownerpwd', 'setNoPrint' => True, 'setNoModify' => True, 'setNoCopy' => True, 'setPageLayout' => Pdfcrowd::CONTINUOUS, 'setPageMode' => Pdfcrowd::FULLSCREEN, 'setFooterText' => '%p/%n | source %u', 'enableImages' => False, 'enableBackgrounds' => False, 'setHtmlZoom' => 300, 'enableJavaScript' => False, 'enableHyperlinks' => False, 'setDefaultTextEncoding' => 'iso-8859-1', 'usePrintMedia' => True, 'setMaxPages' => 1, 'enablePdfcrowdLogo' => True, 'setInitialPdfZoomType' => Pdfcrowd::FIT_PAGE, 'setInitialPdfExactZoom' => 113, 'setPdfScalingFactor' => 0.5, 'setFooterHtml' => '<b>bold</b> and <i>italic</i> <img src="http://s3.pdfcrowd.com/test-resources/logo175x30.png" />', 'setFooterUrl' => 'http://s3.pdfcrowd.com/test-resources/footer.html', 'setHeaderHtml' => 'page %p out of %n', 'setHeaderUrl' => 'http://s3.pdfcrowd.com/test-resources/header.html', 'setAuthor' => 'Custom Author', 'setPageBackgroundColor' => 'ee82EE', 'setTransparentBackground' => True, 'setUserAgent' => "test user agent");