コード例 #1
0
ファイル: Wkhtmltoimage.php プロジェクト: rukzuk/rukzuk
 /**
  * Screenshot wird erstellt
  *
  * @param string $shootId
  * @param \Cms\Business\Screenshot\Url $screenshotUrl
  * @param string $destinationFile
  * @return boolean
  */
 protected function shootImplementation($shootId, $screenshotUrl, $destinationFile)
 {
     $this->options['out'] = $destinationFile;
     $this->options['in'] = (string) $screenshotUrl;
     $this->options['fmt'] = $this->getFiletype();
     $result = wkhtmltox_convert('image', $this->options);
     return $result;
 }
コード例 #2
0
ファイル: test_pdf.php プロジェクト: gooo000/php-wkhtmltox
<?php

foreach (range(1, 4) as $i) {
    wkhtmltox_convert('pdf', array('out' => '/tmp/test' . $i . '.pdf', 'imageQuality' => '95'), array(array('page' => 'http://www.visionaryrenesis.com/'), array('page' => 'http://www.google.com/')));
    // object settings
}
コード例 #3
0
ファイル: test_image.php プロジェクト: gooo000/php-wkhtmltox
<?php

wkhtmltox_convert('image', array('out' => '/tmp/test.jpg', 'in' => 'http://www.google.com/'));
// global settings
コード例 #4
0
 /**
  * {@inheritDoc}
  */
 public function generate($input, $output, $overwrite = true)
 {
     if (!extension_loaded('phpwkhtmltox')) {
         throw new \LogicException('PHP扩展phpwkhtmltox需要先安装.');
     }
     $this->prepareOutput($output, $overwrite);
     $global_options = $this->getOptions();
     foreach ($global_options as $oi => $option) {
         if (null === $option) {
             unset($global_options[$oi]);
         }
     }
     $ext = $this->getDefaultExtension();
     if ($ext === 'pdf') {
         $global_options["out"] = $output;
         $newInput = [];
         if (is_array($input)) {
             foreach ($input as $v) {
                 if (is_array($v)) {
                     if (!empty($v["page"])) {
                         $newInput[] = $v;
                     }
                 } else {
                     $newInput[] = ["page" => strval($v)];
                 }
             }
         } else {
             $newInput[] = ["page" => strval($input)];
         }
         $pages = [];
         foreach ($newInput as $ipt) {
             if (!isset($ipt["page"])) {
                 continue;
             } else {
                 $config = [];
                 if (!empty($ipt["config"]) && is_array($ipt["config"])) {
                     $config = $ipt["config"];
                 }
                 $now = $this->getOptions("object");
                 foreach ($config as $cfgi => $cfgv) {
                     if (isset($now[$cfgi])) {
                         $now[$cfgi] = $cfgv;
                     }
                 }
                 foreach ($now as $oi => $option) {
                     if (null === $option) {
                         unset($now[$oi]);
                     }
                 }
                 $now["page"] = trim($ipt["page"]);
                 $pages[] = $now;
             }
         }
         wkhtmltox_convert($ext, $global_options, $pages);
     } else {
         $global_options["out"] = $output;
         if (is_array($input)) {
             $global_options["in"] = current($input);
         } else {
             $global_options["in"] = strval($input);
         }
         wkhtmltox_convert("image", $global_options);
     }
     $this->checkOutput($output);
 }
コード例 #5
-1
ファイル: test_pdf.php プロジェクト: snagytx/php-wkhtmltox
<?php

$errorlog = array();
$success = wkhtmltox_convert('pdf', array('out' => './out.pdf'), array(array('page' => './test.html')), $errorlog);
if ($success) {
    $output = is_string($success) ? $success : NULL;
    if (!empty($output)) {
        echo $output;
    } else {
        echo 'successful.' . "\n";
    }
    exit(0);
} else {
    echo 'error occurred ...' . "\n";
    foreach ($errorlog as $log) {
        echo $log['status'] . ': ' . $log['message'] . "\n";
    }
    exit(1);
}