Need help in PDF generation because I am doing a project with PHP CodeIgniter.
I need to convert some HTML documents (of min 10 pages) into PDF.
I heard that wkhtmltopdf is good compared to others.
But how to incorporate it into the web pages, since I see it as command line converter.
Any example would be more helpful or any suggestion for a good PDF generator?
Here is a PHP class built on top of wkhtmltopdf: http://code.google.com/p/wkhtmltopdf/wiki/IntegrationWithPhp
Related
I just want to ask if there are any free/opensource or are there even any existing PHP class library that can convert HTML to PHP using the tags as its image source?
Because I have created a web app that contains Google Maps in it and now I want to save the generated map, instead of saving it using printscrn I would like to convert it to PDF. Is it even possible?
Can you give me guys a link to the library if ever there are existing ones?
I have already looked for fpdf and tcpdf but on their examples all images is contained on the file directory.
Thanks
There is the library HTML2PDF (on github) licensed under LGPL. It is based on TCPDF and very easy to use.
I have tried and successfully converted html to pdf using wkhtmltopdf[1] binary sometime back (including images).
Download wkhtmltopdf binary which is compatible to your base server o/s and use a php wrapper class similar to this[2] (i haven't tested this wrapper class[2] but it should serve your purpose)
There are plenty of php wrappers available for wkhtmltopdf binary, so you can find one easily if this[2] didn't work well for your purpose.
[1] http://wkhtmltopdf.org/
[2] http://mikehaertl.github.io/phpwkhtmltopdf/
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.
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'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.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Convert HTML + CSS to PDF with PHP?
I want to convert a web page to a high-resolution PDF suitable for printing. How can I do this?
If you want to do it in code, have a look at HTML2PDF or FPDF, they are php libraries designed to create PDF documents with code.
If you combine HTML2PDF with PHP's output buffering functions
ie
<?php
ob_start();
?>
// put all your html in here
<?php
$data = ob_get_contents();
require('html2pdf.php');
$pdf = new HTML2FPDF();
$pdf->AddPage();
$pdf->WriteHTML($data);
$pdf->Output();
?>
Obviously that is a very rough example but I have used that before within php to generate pdfs. It does have some issues with stylesheets, it seems to ignore most of them. But more control can be gained by using FPDF by itself and manually building the documents.
Try: "wkhtmltopdf" it just work great (and its -open source-). It uses webkit engine (used by safari, chrome browsers) and it is very easy to use :
wkhtmltopdf stackoverflow.com/questions/1878512/ output.pdf
Try it! for Linux and Windows as well. Easy to install. If you use ubuntu, type:
aptitude install wkhtmltopdf
if you want to convert web page using browser, you can use sofware in windows like cutepdf, dopdf etc.
but if you want to convert a web page into pdf by php code (on the fly), there are several ways to convert:
Using library provided, you can try html2pdf (php).
In java / .net a library like pd4ml can be used (even it is not free).
You can use open office converter. It can open multiple doc type, and convert into pdf. Open office provide API (I have tried in java, not php). The flow is same like you open the document, then convert into pdf, but you just do it in your coding. Must have open office server daemon to listen the converter via your code. See here http://oodaemon.sourceforge.net/
If you want quick solution in PHP, maybe you can use html2pdf.
The advantage you use open office converter is the output will be same as you see in browser (I already test it use oodaemon). If using library I am not sure 100% it will be same if you open in browser, because the layout is depend on CSS. pd4ml generate layout in pdf base on html and css (has it owns CSS parser I think)