I was trying to create PDF file using Tcpdf engine and CakePDF plugin.
It works ok, but I don't have Polish characters - despite of setting coding to UTF-8.
This is my function for creating PDF and sending it as response object:-
public function create_pdf($id=null)
{
$this->request->allowMethod(['post', 'create_pdf']);
$CakePdf = new \CakePdf\Pdf\CakePdf();
$billboard = $this->Billboards->get($id,['contain' => ['Clients','Photos']]);
$CakePdf->viewVars(array('billboard' => $billboard));
$CakePdf->template('create_pdf');
$CakePdf->encoding('UTF-8');
$pdf = $CakePdf->output();
$this->response->body($pdf);
$this->response->type('pdf');
$this->response->download('tomart_billboard_'.$id.'.pdf');
return $this->response;
}
Here is my configuration of CakePDF plugin:-
Configure::write('CakePdf', [
'engine' => 'CakePdf.Tcpdf',
'margin' => [
'bottom' => 15,
'left' => 0,
'right' => 0,
'top' => 0
],
'orientation' => 'landscape',
'download' => true
]);
Template create_pdf.ctp has encoding set to UTF-8 as well.
In place of Polish characters I have "?" character.
I'm using latest version of Tcpdf, CakePDF and CakePHP 3.