I would like you to help me with this problem, this is my first encounter with mPDF, which I think is wonderful, but I want to display a report with the same font type as my website, which is explained in its documents how to achieve this, but it still does not work for me. So far I have been doing the following:
- Add the Open Sans URL from Google to my document after it
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'> . then I add a stylesheet file containing the font <link rel="stylesheet" href="<?php echo base_url(); ?>assets/publicidad/css/reporte.css" type="text/css"> Inside reporte .css, which I already added, I have a definition to use the Open Sans font
body {font-family: "Open Sans", Sans-Serif; } which displays the font as expected.
- I am creating pdf with mPDF that works well, but when I want to use Open Sans as documentation stands without displaying the font I need, I downloaded the ttfs file from "Open Sans" from http://www.fontsquirrel.com/fonts/ open-sans , and added to the ttfonts folder of the mPDF directory, as he says in his documentation.
After that, I follow this clear documentation http://mpdf1.com/manual/index.php?tid=453 , but still I donโt get the desired font displayed in my PDF document that I didnโt still have it the part that says: "4. To use the font with certain languages, you also need to edit the configuration file (config_cp.php), imagine that Frutiger contains the full set of characters needed for the Thai language:" but I donโt think that the problem is because I am using the default configuration that I suppressed.
function pdf_create($html, $filename, $stream = TRUE) { require_once(APPPATH . 'helpers/mpdf/mpdf.php'); $mpdf = new mPDF(); $mpdf->SetAutoFont(); $mpdf->WriteHTML($html); if ($stream) { $mpdf->Output($filename . '.pdf', 'D'); } else { $mpdf->Output('./uploads/temp/' . $filename . '.pdf', 'F'); return './uploads/temp/' . $filename . '.pdf'; } }
and in my controller I do this.
$html = $this->load->view('publicidad/reporte_x_curso', $data, true); $this->load->helper('mpdf'); pdf_create($html, 'Reporte_por_cursos', true);
(the above is not recognized by the stackoverflow editor)
And finally, what I have done so far is that I should do everything that I want, following the documentation:
$this->fontdata = array( "'Open Sans'" => array( 'R' => 'OpenSans-Regular.ttf' )
PD: I put single quotes because I added this path to my html document, but I also tried without them, without success. Hope you can help me, thanks in advance.