Forums

Tcpdf and php condition

parsifaltheking 20 Oct, 2015
Hi, i've installate tcpdf action and it works.
But i've the necessity to show in pdf an image sign according to user selected in a drop down.
I've add in body of tcpdf action the code <?php ?> and inside using echo showing different img path but it not works.. it print the php code on pdf... there is a way to use php in body of tcpdf?
GreyHead 20 Oct, 2015
Hi parsifaltheking,

No, I don't think so. but you can use a Custom Code action before the TCPDF action, put the PHP in there and add the result to the $form->data[''] array e.g. $form->data['image'] = . . .; Then you can use {image} in the TCPDF body.

Bob
parsifaltheking 21 Oct, 2015
In custom code before tcpdf i've add
if ($form->data['tecnico'] == 'Andrea') {
    $form->data['image'] ="<tr><td><img src="/file/firmaa.jpg" ></td><td></td></tr>";
}
elsif   ($form->data['tecnico'] == 'Claudio') OR  ($form->data['tecnico'] == 'Claand'){
  $form->data['image'] ="<tr><td><img src="/file/firmac.jpg" ></td><td></td></tr>";
}
else {}
and in tcpdf body i've used {image} but i've this error:

Parse error: syntax error, unexpected '" ></td><td></td></tr>"' (T_CONSTANT_ENCAPSED_STRING) in /var/www/vhosts/netservices.it/httpdocs/joomla/administrator/components/com_chronoforms5/chronoforms/actions/custom_code/custom_code.php(20) : eval()'d code on line 5

and not work.
GreyHead 21 Oct, 2015
Hi parsifaltheking,

Please check your typing, you can't use "" inside "" in the <img> string and it should be elseif, not elsif

Bob
parsifaltheking 28 Oct, 2015
Thank's i've correct the error and now it works.. but i've another problem:

1) how i can pass a text to footer section of tcpdf document?
2) how i can do to obtain on pdf created a carriage return of text? because i've a text in input textfield in witch i go to return carriage but on pdf all is on the same line..

Thanks
GreyHead 28 Oct, 2015
Hi parsifaltheking,

a. I don't think that you can put variable text of any kind into a header or footer. Just the text string you set in the action :-(

b. Use the PHP nl2br() function to replace the line-breaks with HTML <br /> tags in the textarea content.

Bob
This topic is locked and no more replies can be posted.