I'm faced with having to generate some fairly basic PDFs on a server which is running php 4.3.2 unfortunately.
So that pretty much renders most things impossible such as google's domPDF etc.. PDFlib is not compiled in so I can't use any of that either.
Does anyone have any suggestions?
Thanks!
use this R&OS PDF Class to achieve this task.. This is fairly simple and light weight class and requires no module etc to be installed on the server.
You could try out DocRaptor.com, which is a webservice that will let you convert html to pdf.
I ended up using an older version of fpdf and HTML2PDF (from the link below.) It's certainly not ideal, but then neither is a 7 year old version of php.
http://www.macronimous.com/resources/Converting_HTML2PDF_using_PHP.asp
You didn't mention if you were generating these from scratch or from existing PDF data. pdftk is a handy PDF manipulation library. You can shell out to it from PHP.
Related
I've been looking around for a good HTML to PDF converter via PHP. But all the information I've gathered is from 2010 or earlier which gives distorted image in my opinion because ever since those libraries were made or used or whatever, HTML5 and CSS3 wasn't in the picture yet. So now I'm wondering which library is nowadays still working flawless and is worth trying out.
I've found a couple of libraries and I was wondering if these are good enough these days but if you have another example, library or script. Please do tell
DOMPDF
mPDF
fPDF (don't think this one is an option but I've seen a lot of scripts using fPDF as foundation)
HTML2PDF and HTML2PS
Thanks in advance!
You might want to try using phantomjs headless browser with some PHP library of your choice.
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
I think that reporting in PHP is very hard. I tried the raw methods of FPdf or R&OS but i would like to know if there is something more friendly to use like JasperReport or Adobe LiveCycle.
I saw somewhere the php javabridge to run jasperreport from php, but i don't like very much this solution.
What do you use for php reporting? Don't you think that fPdf or smiliar are not very friendly for standard reports?
Thank you.
Personally I use PHPExcel for creating Excel files and TCPDF for PDF. Both are very well written object oriented libraries and don't need any external extensions.
What do you mean by php reporting?
For generating PDF files I use and highly recommend mPDF, which does not require any special extensions on the server.
i run a job search site, and i need to convert doc, docx and pdf files into HTML on linux CentOS server running php. People submit these files as resumes. So far, I found PHPDocx to be great at converting docx to html. But I am stuck at doc/pdf. PDFTOHTML gives error "bad color" when i run tests. As far as doc, i only found wvwave, which seems complex and bulky to install.
does anyone have any ideas on how to easily convert doc/pdf to HTML?
The only thing i can think of is FPDF.
It is intended for creating PDF files in PHP but it can also open PDF files.
Maybe you can use that as a base and develop some sort of toHTML function for it.
It is completely free to use and it has some extensions already.
It MIGHT help you.
http://www.fpdf.org
EDIT:
Thanks for the addition to my post in the comments to Pierre:
You can use fpdi: http://www.setasign.de/products/pdf-php-solutions/fpdi but the input pdf is just like an image.
I havent taken a look at it myself so far but this might help.
As far as .doc files go how about trying OpenOffice/LibreOffice, something like:
lowriter -convert-to html doc_file.doc –
As far as PDF goes, if the PDF is a graphical representation of text then you're out of luck, best you can do is try convert it to an image with ImageMagick, if it is a proper text it should easily convert.
There are various tools out there already to do this, such as http://dag.wieers.com/home-made/unoconv/, http://www.phpdocx.com/ (which you've already tried)
http://www.phplivedocx.org/2009/08/13/convert-docx-doc-rtf-to-html-in-php/ looks promising.
Or, you could install a portable version of libreoffice on your server which allows command line conversion
https://help.libreoffice.org/Common/Starting_the_Software_With_Parameters
I'm sure there'll be tutorials out there (on libreoffice support area)
To easily convert pdf to html, I would suggest pdf2htmlEX which produces outstanding HTML and is fast enough for runtime converting. You should first put some effort to optimize and build it for your system. There is simple build howto included on the project link.
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