使用PHP codeigniter以PDF格式下载网页

使用PHP codeigniter以PDF格式下载网页

问题描述:

I want to download my current web page into pdf on click of download button.Is it possible to do this using php codeigniter or javascript(jquery).Please suggest me.

我想点击下载按钮将我当前的网页下载到pdf。是否可以使用php执行此操作 codeigniter或javascript(jquery)。请建议我。 p> div>

There are many ways to do this. You can do this on the server side or you can use html5 or a jquery plugin to do this on the client side.

If you're doing it on the server side use a php library such as dompdf or tcpdf and create the file on the server and make it downloadable using proper headers.

If you're doing it on the client browser use a js plugin like jspdf. There are pros and cons on both methods.

You have to use third party tools like tcpdf to convert your html into pdf document.

it is simple to convert your web-page into pdf format.

you can use mPDf or you can use phantomjs

I've use both in may project, work perfect. using phantomjs you can convert your web-page in many formats.

mPDF example:

http://mpdf1.com/manual/index.php?tid=457

phantomjs:

http://phantomjs.org/examples/

in following example is for png or pdf

https://github.com/ariya/phantomjs/blob/master/examples/rasterize.js

I've successfully used html2pdf for a couple of years until now and it worked every time.

Use DOMPDF for create pdf from php.

Download it from below link : https://github.com/dompdf/dompdf