0

I've created a htm file with php code inside, that's very huge file i will summarize here.

<?php
//database connection and query and storing data in php variables 
?>
<html>
<head>
</head>
<body>
<p><?php echo "firstname ". $var1 ?></p>
<p><?php echo "firstname ". $var2 ?></p>
<p><?php echo "firstname ". $var3 ?></p> 
</body>
</html>

I'm getting output .htm file with echoing php variables successfully, now end of html file I want to create a button for save as pdf option and convert the entire document to pdf for user using php, I gone through tcpdf file but didn't find any useful source to add php code within $html.

Registered User
  • 1,554
  • 3
  • 22
  • 37
  • Either output buffer the script execution that generates the html file or save it as a file, than pass that to tcpdf or dompdf or mpdf or any of the other libraries that convert html to pdf... there shouldn't be any PHP in the __output__ of the script, so why do you need a way of adding php code to $html? – Mark Baker Jan 13 '14 at 09:08

5 Answers5

0

Probably you will need to install wkhtmltopdf library and then call the 'exec' function to generate pdf from html.

exec('wkhtmltopdf http://google.pl google.pdf');
Piotr Pasich
  • 2,639
  • 2
  • 12
  • 14
0

You just refer dompdf. I think it is easy to convert in pdf.

refer: http://code.google.com/p/dompdf/

ReNiSh AR
  • 2,782
  • 2
  • 30
  • 42
Anand Somasekhar
  • 596
  • 1
  • 11
  • 20
0

TCPDF is simple and easy to use...

http://www.tcpdf.org/ here you can find examples and can use them...

Also, I have problem with UTF-8 characters from MySql, for everything else is very good..

Pavle

Pavlen
  • 129
  • 1
  • 12
0

http://pd4ml.com/php.htm is a step-by-step instruction how to implement "As PDF" button (and to hide the button in the resulting PDF) using PD4ML.

zfr
  • 339
  • 4
  • 11
0

A simple html generating library for PHP can be here:

http://fpdf.org

just go through it.

ReNiSh AR
  • 2,782
  • 2
  • 30
  • 42