PHP PDF functions - php

How do I generate PDF files with PHP. php.net says that pdflib needs to be installed to use functions such as new_pdf ().
However, pdflib is not free and the lite version is not allowed for commercial use. I am confused. I would have thought PHP would have some built-in functionality to create PDF files.
How do I get through this as I do not want to use libraries such as fpdf, etc.?

You should try the following. They are some useful PHP libraries for PDF documents:
TCPDF
mPDF
DOM PDF
See Stack Overflow questions Generate PDF from HTML PHP and How to generate PDF files with PHP?.
It's your choice with which you feel more comfortable.

PHP does not have any in-built functions, so you have to use libraries. TCPDF is the easiest modules and it's free.

If you don't want to use pdflib, you will have to use another third-party library.
Zend provides one as part of the Zend Framework. But the ones we have used for various purposes are:
DomPDF is great for taking HTML and producing PDF files
tcPDF is a more class-based drawing style approach, but it works great and gives loads of control.

Related

reports in PDF with tables in PHP

I have to generate few reports in PDF format with some inventory stats (no graphs, only tables). Additionally, I have to generate some pdf labels for the placed orders and units in a nice tabular format (taking care of landscape orientation and line wrapping) for the web platform. Which PHP API/Library would be best suitable for this purpose. I am using Zend framework but Zend's PDF API is not rich enough to serve the cause.
One option I am considering is to use LateX for generating PDFs.
Advices? Suggestions?
There are several PDF generation libraries and executables.
I've used:
TCPDF
DOMPDF
html2pdf as #redreggae suggested
wkhtmltopdf
Many other alive & dead solutions
They all rendered HTML to PDF. The problem of all (except wkhtmltopdf) was that they all used different (non-standard) rendering engines and results were often different between them and unsatisfying. wkhtmltopdf uses WebKit to interpret the HTML and create a pdf file. I personally prefer wkhtmltopdf after trying/using (in production) all other of the ones listed.. There is one drawback to it - it is an executable and as such it must be called with exec() however this should not be a big issue when proper coding is applied such that you prevent code injection.
If you want something higher level than HTML to PDF converters, you can try PHPJasperXML, it's a renderer for JasperReports on pure PHP.

Suitable library to write PDF using Code igniter

Which library is best to write PDF from HTML using Code Igniter?
Right now I'm using TCPDF, and it's taking much time to load a library.
Following are some useful PDF libraries & Tutorials for Codeignitor
PDF generation using dompdf
TCPDF-CodeIgniter Integration
Generating PDF files using CodeIgniter
mPDF with CodeIgniter
generating PDF files
Check out this article. The PDF library used there is quite fast and easy to use.
Since you're looking to convert HTML to a PDF, I highly recommend the wkhtmltopdf. It uses Qt and WebKit to generate PDF files of rendered markup, and even handles moderately complex JavaScript and AJAX. This makes it really useful for generating PDFs of pages that you have already created views and templates for, with the added benefit of being able to tweak and debug these pages with your browser. It works great for generating platform agnostic print views in your web app by normalizing the many nuances of various combinations of operating systems, web browsers, and printer drivers.
It's a stand-alone binary, so you may have trouble implementing it on shared hosting, but I used it recently on a project and could not have been more happy with it.
wkhtmltopdf: http://code.google.com/p/wkhtmltopdf/
My personal favorite PHP Library and API for it:
https://github.com/mikehaertl/phpwkhtmltopdf
Check out R&OS library R&OS pdf
i find it easy to implement

How to view/convert uploaded file in/to pdf?

i am building a simple system using PHP that allow people to Add, Delete, and View data.
Can anyone tell me how to view the uploaded data in PDF format?
There are a bunch of options. The ones I like are:
wkhtml2pdf - A command-line tool that uses the WebKit HTML rendering engine to generate PDFs from HTML docs. Very easy to use, assuming you're able to get it installed on your server, and your requirements aren't too stringent. You just generate HTML/CSS, and use PHP's shell-exec functions to run it, and voila.
Zend_Pdf - Part of the Zend Framework, but like almost all ZF components, you can use it stand-alone. Programmatically build PDFs.
tcpdf, fpdf (with fpdi if you want to import existing PDFs and write over the top of them) - older, uglier, but effective.
There's also the commercial PDFLib, which used to be the best thing around, but I don't remember much about it. Included for approximate completeness.
Take a look at PDFLib, or its deprecated predecessor.

How can I generate a PDF from HTML without the PDFlib library?

I need to dinamicaly generate a PDF from HTML, but I have PDF Support disabled on my hosting, so is it possible to do without PDFlib GmbH library?
Thanks
There are many packages, but as I gather you're not able to install extra libs on your hosting. Options would be FPDF if you feel like rewriting your whole HTML into blocks, TCPDF if you feel a bit less masochistic, which has some limited html/css support.
The most common alternative is FPDF. It is pure PHP and needs no installed extensions.
An other nice option is dompdf, which is a HTML to PDF converter and is (almost) CSS 2.1 compliant. It can be used either using PDFLib or the R&OS CPDF class
You could also checkout htmldoc:
Project page

PHP library to read PDFs?

Do you know of any free libraries to read PDFs in PHP, the built in PDF functionality is only for rendering PDF output.
Once again, Zend Framework strikes : Zend_Pdf is a PDF (Portable Document Format) manipulation engine. It can load, create, modify and save documents. Thus it can help any PHP driven application to dynamically create PDF documents by modifying existing templates or generating new ones from scratch. [...]
Once again, Zend Framework strikes :
Zend_Pdf is a PDF (Portable Document
Format) manipulation engine
Don't forget that Zend Pdf is appliacable to use in NON-Zend environment. Most of Zend componemts are easy pluggable to any PHP application.
If your webserver is Unix, use the pdftotext utlity to dump the PDF to text, then display it how you want it. It's not going to have the formatting, but the text will be available.
You can use FPDI to read pdf and translate them in fpdf
You can use phpLiveDocx to convert PDF, DOC, DOCX, RTF etc to TXT. For details see http://www.phplivedocx.org

Categories