예제 #1
0
파일: Pdf.php 프로젝트: nabble/ajde-core
 private function snappy($url)
 {
     $bin = PHP_INT_SIZE === 8 ? 'bin/wkhtmltopdf-amd64' : 'bin/wkhtmltopdf-i386';
     $snappy = new \Knp\Snappy\Pdf(Config::get('local_root') . '/' . VENDOR_DIR . $bin);
     $snappy->setOption('print-media-type', true);
     $snappy->setOption('disable-javascript', true);
     $snappy->setOption('lowquality', false);
     $snappy->setOption('load-error-handling', 'ignore');
     // Use $snappy->getOptions() to see all possible options
     // @see http://wkhtmltopdf.org/usage/wkhtmltopdf.txt
     // d($snappy->getOptions());exit;
     return $snappy->getOutput($url);
 }
예제 #2
0
파일: index.php 프로젝트: nabble/web2pdf
<?php

if (!isset($_GET['url'])) {
    die('No URL specified');
}
if (!isset($_GET['filename'])) {
    die('No filename specified');
}
require_once 'vendor/autoload.php';
$url = filter_var($_GET['url'], FILTER_SANITIZE_URL);
$filename = $string = preg_replace('/[^ \\w]+/', '', $_GET['filename']);
file_put_contents('log/requests.log', PHP_EOL . date('c') . ' - ' . $url . ' - ' . $filename, FILE_APPEND);
$root = $_SERVER['DOCUMENT_ROOT'] . str_replace('/index.php', '', $_SERVER['PHP_SELF']);
$bin = PHP_INT_SIZE === 8 ? '/vendor/bin/wkhtmltopdf-amd64' : '/vendor/bin/wkhtmltopdf-i386';
$snappy = new \Knp\Snappy\Pdf($root . $bin);
$snappy->setOption('print-media-type', true);
$snappy->setOption('disable-javascript', true);
$snappy->setOption('lowquality', false);
// Use $snappy->getOptions() to see all possible options
// @see http://wkhtmltopdf.org/usage/wkhtmltopdf.txt
// d($snappy->getOptions());exit;
header("Content-Type: application/pdf");
header("Content-Disposition: attachment; filename='" . $filename . ".pdf'");
file_put_contents('log/requests.log', ' - OK', FILE_APPEND);
echo $snappy->getOutput($url);
예제 #3
0
<?php

error_reporting(E_ERROR & ~E_NOTICE);
$root = dirname(__DIR__);
$loader = (require $root . '/vendor/autoload.php');
$loader->add('', $root . '/classes/');
$pixie = new \App\Pixie();
$pixie->bootstrap($root);
$snappy = new \Knp\Snappy\Pdf($pixie->config->get('parameters.wkhtmltopdf_path'));
//$snappy->setOption('cookie', $_COOKIE);
$snappy->setOption('viewport-size', '800x600');
$snappy->setOption('toc', false);
$snappy->setOption('outline', false);
$snappy->setOption('outline-depth', 0);
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="receipt_' . $order->uid . '_' . date('Y.m.d') . '.pdf"');
echo $snappy->getOutput('http://google.com');