Как показать ориийский (индийский) язык в TCPDF - PullRequest
0 голосов
/ 12 февраля 2019

Я пытаюсь сгенерировать PDF с моим государственным языком.И у меня нет проблем с генерацией.

Моя проблема в том, что я не могу создать PDF с языком oriya.

Я пытался использовать DejaVuSans и некоторые другие шрифты, но безуспешно я получил некоторые другие шрифты формата.

Вот мой код.

HTML

$html = '<html>
                        <head>
                        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                        <style>
                            body { font-family: DejaVu Sans, sans-serif !important; }                            
                        </style>
                        <title>Lightning Bulletins</title>
                        </head>
                        <body>
                        <table width="100%" valign="middle">
                            <tr>
                                <td width="5%"><img src="' . base_url() . 'stylesheet/images/Logo_Odisha2.png" border="0" /></td>
                                <td colspan="2" width="90%" align="center" valign="middle"><font style="font-family:Times New Roman; font-size:18px">
                                    ODISHA STATE DISASTER MANAGEMENT AUTHORITY </font>
                                </td>
                                <td width="5%" ></td>                         
                            </tr>

                            <tr>
                                <td colspan="4" width="100%" align="center" valign="middle" style="font-family:Times New Roman; font-size:12px" >Rajiv Bhawan, Unit 5, Bhubaneswar</td>
                            </tr>

                            <tr><td align="center" colspan="4" style="font-size:2px; border-bottom:#000 5px double; ">&nbsp;</td></tr>

                            <tr><td align="center" colspan="4" style="font-size:4px; ">&nbsp;</td></tr>

                            <tr><td align="center" colspan="4" valign="middle"><font style="font-family: Impact; font-weight:bold; serif; font-size: 20px; font-weight: 500; line-height: 26.4px;">Lightning Bulletins for - [ ' . $districts . ' ]</font></td></tr>

                            <tr><td align="center" colspan="4" style="font-size:2px; border-bottom:#000 5px double; ">&nbsp;</td></tr> 
                                <tr valign="middle">
                            </tr> 

                            <tr><td></td></tr>

                            <tr>
                                <td colspan="5" align="center" style="font-size:10px;">
                                <h2>Dos and Donts</h2>'.$dos_dont.'</td>
                            </tr>

                            <tr>
                                <td align="center" colspan="4" style="border-left: 1px thin #CCC;border-right: 1px thin #CCC;font-size:4px;">&nbsp;</td>
                            </tr>
                            <tr>
                                <td colspan="4" style="font-size:10px;border-left: 1px thin #CCC;border-right: 1px thin #CCC;font-size:4px;border-bottom: 1px thin #CCC;font-size:4px;">&nbsp;</td>
                            </tr>
                            <tr>
                                <td align="center" colspan="4" style="font-size:7px;">&nbsp;Powered by <font color="#3399FF"> Regional Integrated Multi-Hazard Early Warning System (RIMES)</font>
                                </td>
                            </tr>
                        </table>
                        </body>
                    </html>';

PDF-код

$pdf = new PDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
                    // set document information
                    $pdf->SetCreator(PDF_CREATOR);
                    // set default header data
                    $pdf->setPrintHeader(false);
                    $pdf->setPrintFooter(false);
                    //====================================================================================================+   
                    // set default font subsetting mode
                    $pdf->setFontSubsetting(true);

                    // Set font
                    // dejavusans is a UTF-8 Unicode font, if you only need to
                    // print standard ASCII chars, you can use core fonts like
                    // helvetica or times to reduce file size.
                    //$fontname = TCPDF_FONTS::addTTFfont('/tcpdf/fonts/DejaVuSans.ttf', 'TrueTypeUnicode', '', 96);
                    //$pdf->SetFont($fontname, '', 14, '', false);
                    //$pdf->SetFont('DejaVuSans', '', 14, '', true);
                    //$fontname = TCPDF_FONTS::addTTFfont('../tcpdf/fonts/ARIALUNI.ttf', 'TrueTypeUnicode', '', 32);
                    $pdf->SetFont('dejavuserifcondensed', '', 14);

                    /*$font = $this->addTTFfont("DejaVuSans.ttf");
                    $pdf->SetFont($font, '', 14, '', false);*/
                    // Add a page
                    // This method has several options, check the source code documentation for more information.
                    $pdf->AddPage();
                    // set auto page breaks
                    $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
                    //====================================================================================================+
                    $html = utf8_encode($html);
                    //====================================================================================================+
                    // Print text using writeHTMLCell()
                    //$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
                    $pdf->writeHTML($html, true, false, true, false, '');
                    //====================================================================================================+
                    // Close and output PDF document
                    // This method has several options, check the source code documentation for more information.
                    //$name = ROOT_DIR . '/files/'.$username.'/bulletin.pdf';
                    $pdf->Output(ROOT_DIR . '/assets/uploads/lightning_bulletin/lightning_bulletin_'.date('Y-m-d-H-i-s').'.pdf', 'F');
                    // $pdf->Output('bulletin.pdf', 'I');
                    //====================================================================================================+
                    // END OF FILE
                    //====================================================================================================+  
                    // $this->view(ROOT_DIR . '/assets/uploads/mail_uploads/bulletin_'.$date_str.'.pdf');
                    echo json_encode(array('url'=>base_url() . '/assets/uploads/lightning_bulletin/lightning_bulletin_'.date('Y-m-d-H-i-s').'.pdf'));

Любая помощь с этим очень ценится.

...