i want to make a pdf file with the help of php code if suppose i make a register form after click the submit button that form information must com开发者_运维知识库e to pdf file. is there any way to do. i got a one link but that PDF is not working properly i have been searching but still i can't get the demo.
you guys can any one help me.
thanks
Try FPDF library. I am posting part of code I used for generating pdf dynamically in php.
require_once('fpdf/fpdf.php');
$frontpdf = new FPDF('P', 'mm', 'A4');
$frontpdf->AddPage();
$frontpdf->SetFont('Arial','',12);
$frontpdf->Cell(210, 230.19, $frontpdf->Image('./images/cover.jpg', 0, 0, 205, 230.19));
$frontpdf->Ln(218);
$frontpdf->Cell(110,6,$fname.' '.$lname,0);
$frontpdf->Ln();
$frontpdf->Cell(110,6,date('d.m.Y'),0);
$frontpdf->Output('./pdfs/your_data.pdf', 'F');
For details see http://www.fpdf.org/
Use 'I' or 'D' instead of 'F' in last line if you want to send pdf file instead of saving it. You can use FPDF in php4 as well.
Copied from here:
<?php
// We'll be outputting a PDF
header('Content-type: application/pdf');
// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');
// The PDF source is in original.pdf
readfile('original.pdf');
?>
Set the action url of your form to a php file like the one above.
You will need a pdf generator and i recommend you to use tcpdf:
http://www.tcpdf.org/
It is open source and when you download the library you have more than 50 or 60 how to use example scripts.
Unlike other open/source libraries i know that this one actually supports utf-8 (depends on the font used). I tested fpdf, dompdf and few others becouse i needed these characters in my documents: č, ć, ž, š, đ and that is the only library i could use for that.
If you need a specific example show me your code and i'll help you :)
精彩评论