/***********************************************

Untuk configurasi dom pdf di zend,anda dapat menggunkan code sebagai berikut :
function printAction(){
$tmps=explode("/",$_SERVER['REQUEST_URI']);
$idView=$tmps[5];
$data=new SaveModel();
$dataAll=$data->getAll($idView);
$cat=$this->note($dataAll->tgl,$dataAll->biodata_nama);
$this->view->assign('data',$dataAll);
$this->view->assign('cat',$cat);
//echo $idView;
/* $invoicePrint="<div style='color:#F00;'>ini merah</div>";
$dompdf = new DOMPDF();
$dompdf->load_html($invoicePrint);
$dompdf->render();
$dompdf->stream("sample.pdf"); */
$html = $this->view->render("PDFLayout.phtml");
$dompdf = new DOMPDF();
$dompdf->set_paper("a4","portrait");
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("Biodata_".$dataAll->biodata_nama.".pdf");
//$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
}

File di print.phtml
<style>
body {
margin: 65pt 28pt 40pt 28pt;
font-size: 1em;
}
</style>
<body>
<script type="text/php">

if ( isset($pdf) ) {

$font = Font_Metrics::get_font("verdana");;
$size = 6;
$color = array(0,0,0);
$text_height = Font_Metrics::get_font_height($font, $size);

$foot = $pdf->open_object();

$w = $pdf->get_width();
$h = $pdf->get_height();

// Draw a line along the bottom
$y = $h - $text_height - 24;
$pdf->line(16, $y, $w - 16, $y, $color, 0.5);

$pdf->close_object();
$pdf->add_object($foot, "all");

$header = $pdf->open_object();
$pdf->image("../public/Logo.png",'png',200,10, 200,50);
$pdf->close_object();
$pdf->add_object($header, "all");

$text = "Page {PAGE_NUM} of {PAGE_COUNT}";

// Center the text
$width = Font_Metrics::get_text_width("Page 1 of 2", $font, $size);
$pdf->page_text($w / 2 - $width / 2, $y, $text, $font, $size, $color);

}
</script>


0 komentar: