gpt4 book ai didi

php - dompdf 样式在服务器中不起作用

转载 作者:太空宇宙 更新时间:2023-11-04 14:03:34 24 4
gpt4 key购买 nike

我将 dompdf 库与 codeigniter 一起使用以生成 html 格式的报告。在这种情况下,pdf 是在本地机器上生成的。但是当我将相同的代码上传到服务器时机器样式不起作用。但我检查了相关的 html 页面。它以样式显示。

这是我的库文件。

<?php

require_once(dirname(__FILE__) . '/dompdf/dompdf_config.inc.php');

class pdf extends DOMPDF
{

private $html = '';

protected function ci()
{
return get_instance();
}

public function load_view($view, $data = array())
{
$this->html .= $this->ci()->load->view($view, $data, TRUE);
}

public function render($file)
{
// echo $this->html; die;
$this->load_html($this->html);
parent::render();
$this->stream($file);
}
}

我尝试在删除 echo $this->html; 的注释后检查 html;死;

这是我的行为

public function download()
{
$this->load->library('pdf');

$this->pdf->load_view('pdf/header');
$this->pdf->load_view('pdf/test');
$this->pdf->load_view('pdf/footer');

$this->pdf->render('ttt.pdf');
}

和观点

pdf/标题

<!DOCTYPE html>
<html>
<head>
<title>dddd</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="<?php print base_url(); ?>css/pdf.css" rel="stylesheet" media="screen">
</head>
<body>
<div class="container">
<div id="header">
<a href="<?php print base_url(); ?>">
<h2>ddddd</h2>
</a>
</div>
<div id="main">

pdf/测试

<h3>SECTION 17 APPLICATION</h3>
<h4>1) Particulars of Investors</h4>
<table class="table table-bordered">
<thead>
<tr>
<th></th>
<th>US $ Min</th>
<th>%</th>
</tr>
</thead>
<tbody>
<tr>
<td>a) Name :- </td>
<td>tttttt</td>
<td>dfsdfsdf</td>
</tr>
</tbody>
</table>

pdf/页脚

        </div>
<footer>
&copy; <?php print date('Y'); ?> ddddd. All Rights Reserved
</footer>
</body>
</html>

最佳答案

DomPDF 默认不加载外部 CSS 参见:DOMPDF doesn't work with external css file

您还可以查看手册:DOM pdf manual

关于php - dompdf 样式在服务器中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21304667/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com