/** Function to create a nice vendor-styled PDF for the output of the given view. The $path and $dest arguments are directly passed on to TCPDF::Output. To create a PDF directly from a given HTML (i.e. not through a view), one can directly use the VmVendorPDF class, see VirtueMartControllerInvoice::samplePDF */ static function createVmPdf($view, $path = '', $dest = 'F', $meta = array()) { if (!$view) { // TODO: use some default view??? return; } if (!class_exists('VmVendorPDF')) { vmError('vmPdf: For the pdf, you must install the tcpdf library at ' . VMPATH_LIBS . DS . 'tcpdf'); return 0; } $pdf = new VmVendorPDF(); if (isset($meta['title'])) { $pdf->SetTitle($meta['title']); } if (isset($meta['subject'])) { $pdf->SetSubject($meta['subject']); } if (isset($meta['keywords'])) { $pdf->SetKeywords($meta['keywords']); } // Make the formatter available, just in case some specialized view wants/needs it $view->pdf_formatter = $pdf; $view->isPdf = true; $view->print = false; ob_start(); $view->display(); $html = ob_get_contents(); ob_end_clean(); $pdf->AddPage(); $pdf->PrintContents($html); // Close and output PDF document // This method has several options, check the source code documentation for more information. $pdf->Output($path, $dest); return $path; }
public function samplePDF() { if (!class_exists('VmVendorPDF')) { vmError('vmPdf: For the pdf, you must install the tcpdf library at ' . VMPATH_LIBS . DS . 'tcpdf'); return 0; } $pdf = new VmVendorPDF(); $pdf->AddPage(); $pdf->PrintContents(tsmText::_('COM_VIRTUEMART_PDF_SAMPLEPAGE')); $pdf->Output("vminvoice_sample.pdf", 'I'); JFactory::getApplication()->close(); }