Custom PDF (Html renderer)

QuestionsCustom PDF (Html renderer)
Richard asked 3 months ago

Original Code:https://gist.github.com/gridphp/6d0d3f720e491261bb43aadded5b6042

Modified code: https://gist.github.com/rmkurzban/4c7c54522b5afc657744e527c531b75a

View post on imgur.com

The orginal code has a typo on line 110 is $html .= “<td class=\”barcode\” $shade>$d</td>”;

should be $html .= “<td class=\”xbarcode\” $shade>$d</td>”;

Missing x in class.

I trying to have conditional color in PDF. I was able to add code for color in the PDF render but it does not come out in the PDF. If the comment is removed from line 148 //phpgrid_error($html); The return does have color. Also I have add  new field to client table see lines13 -14 and the column code 62-79 this works for the grid but for the render and normal PDF  the No is a 0 and Yes works okay.

3 Answers
Abu Ghufran Staff answered 3 months ago

In your modified code:

Line 128: For color export, set inline style instead of class. Also use double quotes OR \” to define styles as below.

$html .= "<tr" . ($v['is_active'] === "Yes" ? " style=\"color:#ff0000\">" : ">");

Ref: https://tcpdf.org/examples/example_048/

PS: thanks for identifying typo

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Abu Ghufran Staff answered 3 months ago

For your second issue, showing 0 instead of No, You need to modify lib/inc/jqgrid_dist.php

Search this block:
if (!empty($rec[$cm[“name”]]))

and replace with:
if ($rec[$cm[“name”]] != ”)

Full code block:

// dropdown mappings

if ($cm["edittype"] == "select" && $cm["formatter"] == "select" && isset($cm["editoptions"]["value"]))
{
	$rec[$cm["name"]] = trim($rec[$cm["name"]]);
	if ($rec[$cm["name"]] != '')
_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Richard answered 3 months ago

Thank you both fixes worked.

Your Answer

0 + 8 =

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?