从我的网站打印内容的最佳方式[关闭]

My website is an intranet for an enterprise, The site contains data about clients, pricing etc stored in a MySQL database but this is not the point.

The site needs to be able to generate bills using the different data like the clients name, address etc ...

The question is simple, which way should I use to generate these pages? I tried to generate a html page but the printing is too much related to the browser, some keep things some don't and I don't like this.

should I generate pdf pages instead and how? thanks you for your answers

EDIT: the site is build using PhP and Javascript

The page need to contain a huge amont of data and therefore can't be handled with html printing

You should indeed generate pdf's. Printing html is quirky at best and you have no foolproof way to ie. make page breaks or force landscape printing.

You can ofcourse us a custom print only css, but that is still very limited.

Also alot of browsers will allways print a tekst on the header and footer on each page, unless the end user disables that specific option.

PDF is the only decent way to go to provide printing.

In general the best way to print complex documents is to generate a PDF from an HTML page, server-side, then serve up the PDF.

This seems to be the popular choice: http://www.tcpdf.org/

If you want to have specific format in these reports you can create pdf's on the fly with libraries like: fpdf or fpdi (to import pdf templates). There is option though to create html content that fit your needs also but maybe its more free to the layout. PDF format is more formal and can put content to exact place of your paper.

FPDF or TCPDF could come in handy.

The good way to solve this problem is find some online service to do this, i tried hard to find the answer and finally i get the pdfcrowd.com.

this website provide a api which you use to generate a pdf file, without any complex code, is simple, the only thing you have to do is register and get the api and serial for active the api, you don't have to pay nothin' for while of course, if you want more you know what u have to do....

Hope it help you, and sorry i'm not good in english....

Here are some libs you can use (in no perticular order)

And finally not a code solution but still another very cheap solution is to install a 'Print to PDF' app on the client machines and teach the people how to 'print to pdf'. For example Google Chrome browser has built in 'Save as PDF' in the print destinations menu (after hitting CTRL-P and then the Change... button located under Destination). There's also free software like dopdf and I'm sure you can find more.