Plugin used: TCODF
Export PDF
Public Function export_pdf ($order _sn) {
Require_once (Fcpath. /shared/plugin/tcpdf/tcpdf.php ');
$pdf = new TCPDF (Pdf_page_orientation, "PT", "A4", True, ' UTF-8 ', false);
$pdf->setfootermargin (50);
$pdf->setimagescale (Pdf_image_scale_ratio);
if (@file_exists (Fcpath. /shared/plugin/tcpdf/examples/lang/eng.php ')) {
Require_once (Fcpath. /shared/plugin/tcpdf/examples/lang/eng.php ');
$pdf->setlanguagearray ($l);
}
$pdf->setmargins (20,50,10, true);
$pdf->addpage ();
$pdf->setfont (' stsongstdlight ', ', 12);
$buffer = $this->assign_value ($order _sn);
$startpos = Strpos ($buffer, ' <!--startprint1--> ');
$endpos = Strpos ($buffer, ' <!--endprint1--> ');
$html = substr ($buffer, $startpos, $endpos-$startpos +strlen (' <!--endprint1--> '));
Header ("content-type:text/html; Charset=utf-8 ");
$name = "Customs_declaration";
$export _name = $name. ' _ '. $order _sn;
$pdf->writehtml ($html, True,false,false,false,false);
$pdf->output ($export _name. PDF ', ' d ');
}
Assigns the retrieved page to a value
Public Function Assign_value ($order _sn) {
Ob_start ();
$this->declaration_print ($order _sn);
$buffer = Ob_get_contents ();
Ob_clean ();
return $buffer;
}
With the OB cache, the dynamic page cache is used for export.
JS Print
<script>
Function Preview (oper) {
if (Oper < 10) {
Get_page_info ();
bdhtml=window.document.body.innerhtml;//get the HTML code for the current page
Sprnstr= "<!--startprint" +oper+ "--";//Set Print start area
Eprnstr= "<!--endprint" +oper+ "--";//Set Print End area
Prnhtml=bdhtml.substring (Bdhtml.indexof (SPRNSTR) +18); To take HTML back from the start code
Prnhtml=prnhtml.substring (0,prnhtml.indexof (EPRNSTR));//Fetch HTML from the end code
window.document.body.innerhtml=prnhtml;
Window.print ();
Prnhtml.print ();
window.document.body.innerhtml=bdhtml;
} else {
Window.print ();
}
}
</script>
PHP enables PDF export and print functionality.