PDF Charset

QuestionsPDF Charset
S19K15 asked 6 years ago

I am using PDF functionality to export an html page but html page is in "Greek" and all characters are displayed as "?" in exported pdf. How can i change this behavior when using html?.

6 Answers
S19K15 answered 6 years ago

I solved my problem by adding this code to the 'jqgrid_dist.php' file.
$fontname = $pdf->addTTFfont('../../lib/inc/tcpdf/fonts/Roboto-Black.ttf', 'TrueTypeUnicode', '', 32);
$pdf->SetFont($fontname, '', 11, '', false);

Is there any way to do it via standard configuration and not via the core code file? If not it will be great to be able to configure it more easily without modifying any source code!

Abu Ghufran answered 6 years ago

You can also connect on_render_pdf event handler and set these params.

$e["on_render_pdf"] = array("set_pdf_format", null);
$g->set_events($e);

function set_pdf_format($arr)
{
$pdf = $arr["pdf"];
$data = $arr["data"];

// enable utf8 font
$pdf->SetFont('cid0jp', '', 11);

}

S19K15 answered 6 years ago

It seem that this code is not working when using "html" type for PDF.
The page gets 500 error.

function set_pdf_format($arr)
{
$pdf = $arr["pdf"];
$data = $arr["data"];

// enable utf8 font
$pdf->SetFont('cid0jp', '', 11);

//html code
$html = …..;
return $html;
}

Abu Ghufran answered 6 years ago

For PDF html renderer, refer code from demos/export/export-pdf-html.php

S19K15 answered 6 years ago

I Have implemented the code from demos/export/export-pdf-html.php but i am unable to use the following code inside the set_pdf_format_x:

$pdf = $arr["pdf"];
$pdf->SetFont('cid0jp', '', 11);

Abu Ghufran answered 6 years ago

This wont work in current build.
We'll add $pdf variable reference in next version.

Your Answer

8 + 5 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?