Reputation: 4330
I use dompdf library with codeigniter to generate report as html. In this case pdf is generate in local machine. But when i upload same code to the server machine styles is not working. But i check the related html page. It is showing with styles.
This is my library file.
<?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);
}
}
I try check html after remove comment of echo $this->html; die;
This is my action
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');
}
And views
pdf/header
<!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/test
<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/footer
</div>
<footer>
© <?php print date('Y'); ?> ddddd. All Rights Reserved
</footer>
</body>
</html>
Upvotes: 0
Views: 11226
Reputation: 1122
DomPDF does not load external CSS by default see: DOMPDF doesn't work with external css file
You can also look into the manual: DOM pdf manual
Upvotes: 1