Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用DomPDF创建日志文件_Php_Logging_Font Awesome_Dompdf - Fatal编程技术网

Php 使用DomPDF创建日志文件

Php 使用DomPDF创建日志文件,php,logging,font-awesome,dompdf,Php,Logging,Font Awesome,Dompdf,我在Web服务器上的DomPDF文档中使用字体时遇到问题。但是,当使用eclecticgeek.com的DomPDF调试助手时,同样的HTML也可以工作。因此,我知道HTML没有问题。以下是工作代码的链接: 我试图在本地Web服务器上填充DomPDF的日志文件,以帮助隔离问题,但没有为我生成任何文件。这是我的完整代码,我试图通过DomPDF的选项设置日志文件,但不确定我是否正确 <?php require_once "sites/all/libraries/dompdf/autoloa

我在Web服务器上的DomPDF文档中使用字体时遇到问题。但是,当使用eclecticgeek.com的DomPDF调试助手时,同样的HTML也可以工作。因此,我知道HTML没有问题。以下是工作代码的链接:

我试图在本地Web服务器上填充DomPDF的日志文件,以帮助隔离问题,但没有为我生成任何文件。这是我的完整代码,我试图通过DomPDF的选项设置日志文件,但不确定我是否正确

<?php

require_once "sites/all/libraries/dompdf/autoload.inc.php";
use Dompdf\Dompdf;

$HTML = <<<HTML
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css">
  <link href="https://fonts.googleapis.com/css?family=Macondo" rel="stylesheet">
  <style type="text/css">
  .fa {
    display: inline;
    font-style: normal;
    font-variant: normal;
    font-weight: normal;
    font-size: 14px;
    line-height: 1;
    font-family: FontAwesome;
    font-size: inherit;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
  </style>
</head>
<body>
  <p><span class="fa fa-envelope"></span> Font awesome doesn't work on my webserver</p>
   <p style='font-family: "FontAwesome"'> &#xf2b9; </p> <span> this also does not work </span>
  <p style='font-family: "Macondo", cursive;'> This font works</p>
</body>
</html>
HTML;

$dompdf = new \Dompdf\Dompdf(array(
    'tempDir' => 'sites/test.com/modules/CCPDF/',
    'isRemoteEnabled' => true,
    'isPhpEnabled' => true,
    'isJavascriptEnabled' => true,
    'pdfBackend' => "CPDF",
    'isHtml5ParserEnabled' => true,
    'logOutputFile' => 'sites/test.com/modules/CCPDF/test.log',
    'DOMPDF_UNICODE_ENABLED' => true
));
$dompdf->load_html($HTML);
$dompdf->setPaper('A4', 'portrait');
$dompdf->render();
$dompdf->stream();

 ?>

这里是我在本地调试时使用的PHP代码片段

ini_set('display_errors', true);
ini_set('error_log', 'output/tester.err.log');
ini_set('log_errors', true);
error_reporting(E_ALL);

$dompdf_options = array(
    'chroot' => '/',
    'logOutputFile' => __DIR__ . '/dompdf.log.html',
    'isHtml5ParserEnabled' => true,
    'debugPng' => false,
    'debugKeepTemp' => false,
    'debugCss' => false,
    'debugLayout' => false,
    'debugLayoutLines' => false,
    'debugLayoutBlocks' => false,
    'debugLayoutInline' => false,
    'debugLayoutPaddingBox' => false
);

$_dompdf_show_warnings = true;
$_dompdf_debug = false;
$_DOMPDF_DEBUG_TYPES = [
   'page-break' => false
];

$dompdf = new Dompdf\Dompdf($dompdf_options);
echo 'Running with ' , $dompdf->version , "\n";
$_dompdf_warnings = array();
echo 'Rendering '. $test_file . "\n";
$dompdf->load_html_file($test_file);
$dompdf->render();
file_put_contents(__DIR__ . '/' . basename($test_file) . (strtolower($dompdf_options['pdfBackend']) === 'gd' ? '.png' : '.pdf'), $dompdf->output(array('compress'=>0)));

您可以使用调试设置来获取不同类型的调试信息。

这里是我在本地调试时使用的PHP代码片段

ini_set('display_errors', true);
ini_set('error_log', 'output/tester.err.log');
ini_set('log_errors', true);
error_reporting(E_ALL);

$dompdf_options = array(
    'chroot' => '/',
    'logOutputFile' => __DIR__ . '/dompdf.log.html',
    'isHtml5ParserEnabled' => true,
    'debugPng' => false,
    'debugKeepTemp' => false,
    'debugCss' => false,
    'debugLayout' => false,
    'debugLayoutLines' => false,
    'debugLayoutBlocks' => false,
    'debugLayoutInline' => false,
    'debugLayoutPaddingBox' => false
);

$_dompdf_show_warnings = true;
$_dompdf_debug = false;
$_DOMPDF_DEBUG_TYPES = [
   'page-break' => false
];

$dompdf = new Dompdf\Dompdf($dompdf_options);
echo 'Running with ' , $dompdf->version , "\n";
$_dompdf_warnings = array();
echo 'Rendering '. $test_file . "\n";
$dompdf->load_html_file($test_file);
$dompdf->render();
file_put_contents(__DIR__ . '/' . basename($test_file) . (strtolower($dompdf_options['pdfBackend']) === 'gd' ? '.png' : '.pdf'), $dompdf->output(array('compress'=>0)));

您可以使用调试设置来获取不同类型的调试信息。

旁注,如果您试图在domPDF版本0.8中使用font awesome,则似乎存在一个问题,即不允许此操作。您最好使用版本0.7.Side注意,如果您试图在domPDF版本0.8中使用font awesome,似乎有一个问题不允许它工作。您最好使用0.7版。谢谢Brian,这应该会有所帮助!谢谢布莱恩,这应该会有帮助!