使用Php / JavaScript / Html / CSS创建可打印的内容
I work for a care centre that would like a feature on their website where friends and family can choose from a selection of care cards to deliver to someone they know. They will be able to choose a title, an image and type in some text on the card that we assemble and deliver. They need me to make an application for them that assembles the cards in a printer-friendly fashion (placing text and images in the right areas) that they will print and fold before delivery.
Image of what I am trying to create: http://i.imgur.com/f8GnD.png
Reading about how to do this I realize that I have two issues:
- Size of card on-screen can't be fixed due to printer DPI
- Should I use html/CSS to make a table with 4 cells to create this card? Php image library? JavaScript?
Any help would great.
我在一个护理中心工作,希望他们的网站上有一个功能,朋友和家人可以选择 护理卡交付给他们认识的人。 他们将能够选择标题,图像并在我们组装和交付的卡片上输入一些文字。 他们需要我为他们制作一个应用程序,以打印机友好的方式组装卡片(在正确的区域放置文本和图像),他们将在交付前打印和折叠。 p>
图像 我想要创建的内容: http://i.imgur.com/f8GnD.png p>
阅读如何做到这一点我意识到我有两个问题: p>
- 屏幕上的卡大小不能 由于打印机DPI而被修复 li>
- 我是否应该使用html / CSS创建一个包含4个单元格的表来创建此卡? Php图像库? JavaScript? li>
ul>
任何帮助都会很棒。 p> div>
I have the best luck, in terms of printing, with PDFs. The document format is nice, too, because it is portable and the user may choose to print somewhere other than where they accessed your site.
The best PDF-generating library I've used for PHP is fPDF: http://www.fpdf.org/
PDFs are great for printing full-page documents. All but the most ancient operating systems provide users the ability to open and print PDFs, and because PDF is a document format the printed output is fairly consistent between systems and printers.
The other route you suggest is certainly possible - you can build it up using HTML and CSS. There are serious drawbacks to this, however. Foremost, each user is going to have varying printer settings in their browser, and the browser is not configured by default to be good to your full-page printing. Most user agents add page numbers, margins, the date & time, the URL.... in short, your print from the browser is going to rely on the user tinkering with their browser print settings. There is nothing you can do to influence these settings from your end.
There are third-party utilities that generate PDFs on the server, based on your HTML. PDFs have solved many print-related issues internally so you don't have to worry about them yourself.