Difference between revisions of "Creating PDF views"
From Joomla! Documentation
Zhang19min88 (talk | contribs) (→Messy code in Chinese environment: new section) |
|||
Line 8: | Line 8: | ||
I don't konw how to solve this. | I don't konw how to solve this. | ||
+ | |||
+ | You might need to install a Unicode font in DOMPDF (do a search on "dompdf unicode" for examples of how to do that | ||
+ | |||
+ | Also try this for the render function: | ||
+ | |||
+ | |||
+ | <source lang="php"> | ||
+ | public function render($cache = false, $params = array()) | ||
+ | { | ||
+ | // mb_encoding foo when content-type had been set to text/html; uft-8; | ||
+ | $this->_metaTags['http-equiv'] = array(); | ||
+ | $this->_metaTags['http-equiv']['content-type'] = 'text/html'; | ||
+ | |||
+ | // Testing using futural font. | ||
+ | // $this->addStyleDeclaration('body: { font-family: futural !important; }'); | ||
+ | $pdf = $this->engine; | ||
+ | $data = parent::render(); | ||
+ | $this->fullPaths($data); | ||
+ | $pdf->load_html($data); | ||
+ | $pdf->render(); | ||
+ | $pdf->stream($this->getName() . '.pdf'); | ||
+ | |||
+ | return ''; | ||
+ | }</source> |
Revision as of 03:21, 8 April 2015
Has anyone tested this method on Joomla! 2.5? EDIT: tested on Joomla! 2.5 and working fine.
Messy code in Chinese environment[edit]
I have tested this articel in my j25 site. Everything work fine.But when I want output some Chinese char to pdf file. the page goes wrong. The Chinese char to be messy code.
I don't konw how to solve this.
You might need to install a Unicode font in DOMPDF (do a search on "dompdf unicode" for examples of how to do that
Also try this for the render function:
public function render($cache = false, $params = array())
{
// mb_encoding foo when content-type had been set to text/html; uft-8;
$this->_metaTags['http-equiv'] = array();
$this->_metaTags['http-equiv']['content-type'] = 'text/html';
// Testing using futural font.
// $this->addStyleDeclaration('body: { font-family: futural !important; }');
$pdf = $this->engine;
$data = parent::render();
$this->fullPaths($data);
$pdf->load_html($data);
$pdf->render();
$pdf->stream($this->getName() . '.pdf');
return '';
}