我正在使用DOMPDF制作可下载的网页。
但有时可行,有时页面耗时很长,最后显示“无法访问此站点,重置连接”。
如何解决这个问题? 它的代码错误或我的webbrowser上的错误?
谢谢:)
function __construct()
{
parent::__construct();
$this->load->model("Mproses");
}
public function download($db,$p,$id) {
// Load all views as normal
$data['hasil'] = $this->Mproses->selectWhere($db,$p,$id);
$this->load->view('hasil',$data);
// Get output html
$html = $this->output->get_output();
// Load library
$this->load->library('dompdf_gen');
$today = date('D-M-Y h:i:s');
// Convert to PDF
$this->dompdf->load_html($html);
$this->dompdf->render();
$this->dompdf->stream($today.".pdf",array('Attachment'=>1));
//or without preview in browser
//$this->dompdf->stream("welcome.pdf");
}
那是我的dompdf控制器
HTML文件我试着下载:
<div class="row">
<div class="container">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Hasil Pengecekan! <p class="pull-right"><a href="<?php echo URL;?>/index.php/home/diagnosa/" style="color:black;"><span class="fa fa-backward" aria-label="Kembali"></span> | <b>Kembali</b></a></p></h3>
</div>
<div class="panel-body">
<p style="color:black;">
<?php if(count($hasil)>0) { ?>
<?php foreach($hasil as $d) { ?>
<hr>
<br>
<center>
<h2 style="color:black;">Hasil Dari User : <?php echo $d->nama; ?></h2>
</center>
<br>
<hr>
<br>
<ul>
<li style="color:black;"><h5>Penyakit</h5><p style="font-size:20px;"><?php echo $d->penyakit;?></p></li>
<li style="color:black;"><h5>Pilihan</h5><p style="font-size:20px;">"<?php echo $d->pil;?>"</p></li>
<li style="color:black;"><h5>Nilai CF</h5><p style="font-size:20px;"><?php echo $d->nilaicf;?> || <?php echo $d->nilaicf*100;?>%</p></li>
</ul>
<?php } ?>
<?php } else { echo 'Maaf Data Yang Dicari Tidak Ada !'; } ?>
</p>
<br>
<hr>
<br>
<center><?php echo anchor(URL.'index.php/topdf/download/riwayat/id_riwayat/'.$d->id_riwayat,'Download',array('style' => 'color:black;font-size:14px;padding:14px;border:1px black solid;')); ?></center>
<br>
</div>
</div>
</div>
</div>
</div>