Printing to PDF in PHP using FPDF -


i trying make function on website whereby article can made pdf file download and/or printing. using fpdf library i'm struggling understand best way pdf page receive information.

what thinking far make hidden form elements within article page , use them send information, take , insert pdf using $_post. like:

<form action="pdf_printer.php" method="post"> <input type="hidden" name="title" value="<?php echo $title; ?>"/> <input type="hidden" name="body_text" value="<?php echo $body_text; ?>"/> <input type="submit" name="submit" value="print"> </form>  

and pdf_printer.php like:

require('fpdf.php');  $pdf = new fpdf(); $pdf->addpage(); $pdf->setfont('arial','b',16); $pdf->cell(60,10, $_post['title'];,0,1,'c'); $pdf->ln(20); $pdf->cell(60,10, $_post['body_text'],0,1,'c'); $pdf->output(); 

i'm sure inefficient way of doing i'm relatively new php don't know how else done. please advise me?

the best way seems make php script generatepdf.php in grab article's text & title, , generate pdf fpdf. in article 12345 can add link generatepdf.php?id=12345 , fetch data database/files , generate pdf user.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -