Convert text to PDF in PHP
What would be the simplest, shortest way to turn a t开发者_如何学运维ext file into a PDF file with PHP? With some basic example code if possible.
I've seen this but the examples don't show how to use a text file as input.
http://uk3.php.net/manual/en/book.pdf.php
Thanks
TCPDF and FPDF can both render PDF output. If you're on a Linux system, you could also call the system's ghostscript to do it.
You'll definitely need a library to write PDFs. I'd say try FPDF.
TCPDF is the best way to convert text or HTML to PDF.
http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf
Throwing Zend_Pdf into the ring as well.
And a somewhat old tutorial to get you started in addition to the extensive docs in the ZF manual:
- http://devzone.zend.com/article/2525
You can use MPDF.
I wrote a smalll instruction:
1) download Full version(http://www.mpdf1.com/mpdf/index.php?page=Download ) and extract inside anyfolder
2) create sample.php
in anyfolder
and insert like this:
<?php
include('./mpdf.php');
$mpdf=new mPDF();
$mpdf->WriteHTML('<div style="color:yellow;">SAMPLE TEXT, WITH HTML TAGS Too!</div>');
$mpdf->Output(); die('');
?>
3) then open sample.php
in your browser to see the result!
MANY OTHER ONES - Convert HTML + CSS to PDF with PHP?
精彩评论