コード例 #1
0
ファイル: index.php プロジェクト: appotter/phppdf
<?php

error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
set_time_limit(0);
require_once __DIR__ . '/get_examples.php';
require_once __DIR__ . '/../lib/PHPPdf/Autoloader.php';
PHPPdf\Autoloader::register();
PHPPdf\Autoloader::register(__DIR__ . '/../lib/vendor/Zend/library');
PHPPdf\Autoloader::register(__DIR__ . '/../lib/vendor/ZendPdf/library');
PHPPdf\Autoloader::register(__DIR__ . '/../lib/vendor/Imagine/lib');
if (!isset($_GET['name'])) {
    echo 'Available examples:<br />';
    $examples = get_examples();
    echo '<ul>';
    foreach ($examples as $example) {
        echo '<li>' . $example . ' (<a href="?name=' . $example . '">pdf</a> or <a href="?name=' . $example . '&engine=image">image</a>)';
    }
    echo '</ul>';
    exit;
}
$engine = isset($_GET['engine']) ? $_GET['engine'] : 'pdf';
// set different way of configuration
//$facade = PHPPdf\Core\FacadeBuilder::create(new PHPPdf\Core\Configuration\DependencyInjection\LoaderImpl())//->setCache('File', array('cache_dir' => __DIR__.'/cache/'))
$facade = PHPPdf\Core\FacadeBuilder::create()->setEngineType($engine)->setEngineOptions(array('format' => 'jpg', 'quality' => 70, 'engine' => 'imagick'))->build();
$name = basename($_GET['name']);
$documentFilename = __DIR__ . '/' . $name . '.xml';
$stylesheetFilename = __DIR__ . '/' . $name . '-style.xml';
if (!is_readable($documentFilename)) {
    die(sprintf('Example "%s" dosn\'t exist.', $name));
コード例 #2
0
ファイル: cli.php プロジェクト: zhangxiaoliu/PHPPdf
<?php

error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
set_time_limit(240);
require_once __DIR__ . '/get_examples.php';
require_once __DIR__ . '/../lib/PHPPdf/Autoloader.php';
PHPPdf\Autoloader::register();
PHPPdf\Autoloader::register(__DIR__ . '/../lib/vendor/Zend/library');
// set different way of configuration
//$facade = PHPPdf\Core\FacadeBuilder::create(new PHPPdf\Core\Configuration\DependencyInjection\LoaderImpl())->setCache('File', array('cache_dir' => __DIR__.'/cache/'))
$facade = PHPPdf\Core\FacadeBuilder::create()->build();
if ($_SERVER['argc'] < 3) {
    echo 'Pass example name and destination file path, for example `cli.php example-name /some/destination/file.pdf`' . PHP_EOL;
    echo 'Available examples:' . PHP_EOL;
    $examples = get_examples();
    die(implode(PHP_EOL, $examples));
}
$name = basename($_SERVER['argv'][1]);
$destinationPath = $_SERVER['argv'][2];
$documentFilename = __DIR__ . '/' . $name . '.xml';
$stylesheetFilename = __DIR__ . '/' . $name . '-style.xml';
if (!is_readable($documentFilename) || !is_readable($stylesheetFilename)) {
    die(sprintf('Example "%s" dosn\'t exist.', $name));
}
if (!is_writable(dirname($destinationPath))) {
    die(sprintf('"%s" isn\'t writable.', $destinationPath));
}
$xml = str_replace('dir:', __DIR__ . '/', file_get_contents($documentFilename));
$stylesheetXml = str_replace('dir:', __DIR__ . '/', file_get_contents($stylesheetFilename));
コード例 #3
0
ファイル: bootstrap.php プロジェクト: appotter/phppdf
<?php

define('TEST_RESOURCES_DIR', __DIR__ . '/PHPPdf/Resources');
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once __DIR__ . '/../lib/PHPPdf/Autoloader.php';
PHPPdf\Autoloader::register();
PHPPdf\Autoloader::register(__DIR__ . '/../lib/vendor/Zend/library');
PHPPdf\Autoloader::register(__DIR__ . '/../lib/vendor/ZendPdf/library');
PHPPdf\Autoloader::register(__DIR__ . '/../lib/vendor/Imagine/lib');
PHPPdf\Autoloader::register(__DIR__ . '/');