Custom pdf render.

QuestionsCustom pdf render.
Montemaggiore Sebastian asked 9 years ago

Hello community!!. I use pdf export with "render_type" = html. Here is my code:


$grid["export"] = array("format"=>"pdf", "filename"=>"pedidos", "heading"=>"Pedidos", "orientation"=>"landscape", "paper"=>"a4");
$grid["export"]["render_type"] = "html";
$grid["export"]["range"] = "filtered";

$e["on_render_pdf"] = array("set_pdf_format", null);

// Esta funciĆ³n de callback permite actuar al capturar el evento "on_render_pdf".
function set_pdf_format($param)
{
$grid = $param["grid"];
$arr = $param["data"];
$pdf = $param["pdf"];

$pdf->SetFont('helvetica', 'B', 11);

$html .= "<h1>".$grid->options["export"]["heading"]."</h1>";
$html .= '<table border="0" cellpadding="4" cellspacing="2">';
$i = 0;
$j=0;
foreach($arr as $v)
{
$shade = ($i++ % 2) ? 'bgcolor="#efefef"' : '';
$html .= "<tr>";
foreach($v as $d)
{
if ($i == 1)
switch ($j)
{
case 0:
$html .= "<td width="50" bgcolor="lightgrey"><strong>$d</strong></td>";
break;
case 1:
$html .= "<td width="130" bgcolor="lightgrey"><strong>$d</strong></td>";
break;
case 2:
$html .= "<td width="150" bgcolor="lightgrey"><strong>$d</strong></td>";
break;
case 3:
$html .= "<td width="80" bgcolor="lightgrey"><strong>$d</strong></td>";
break;
case 4:
$html .= "<td width="75" bgcolor="lightgrey"><strong>$d</strong></td>";
break;
case 6:
$html .= "<td width="90" bgcolor="lightgrey"><strong>$d</strong></td>";
break;
case 7:
$html .= "<td width="70" bgcolor="lightgrey"><strong>$d</strong></td>";
break;
case 11:
$html .= "<td width="70" bgcolor="lightgrey"><strong>$d</strong></td>";
break;
default:
$html .= "<td width="60" bgcolor="lightgrey"><strong>$d</strong></td>";
}
else
$html .= "<td $shade>$d</td>";
$j = $j+1;
};
$html .= "</tr>";
};
$html .= "</table>";
return $html;
};

Does someone know why this line "$pdf->SetFont('helvetica', 'B', 11);" doesn't work?.
Thanks!!.

2 Answers
Montemaggiore Sebastian answered 9 years ago

In fact, when i use $grid["export"]["render_type"] = "html"; none sentence of the PDF format customization API works.

Abu Ghufran answered 9 years ago

You are right, in lib $pdf is instantiated after the event.

You can edit lib/inc/jqgrid_dist.php and search/replace this:
$pdf->SetFont('helvetica', '', 12);

Your Answer

2 + 19 =

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?