Hi everyone!
I am interested in creating a "print server" for my web application and I've thought about various ways to solve the problem and came up with this solution. I found a plug-in for firefox that will get it to print from the command line (including PDF files). So I want to install FF on my Ubuntu10 server, then have my PHP scripts call FF through the command line to print to PDF the specified URL. When the operation is complete the PHP script will pick-up the generated file and send it out to the user.
Are there any issues with installing FF with no GUI on an Ubuntu server installation? Is there any obvious bottleneck's to this solution? I've been working for the last hour or so to get Firefox to run from the command line and it keeps telling me "Error: no display specified" , which makes sense as I'm running a headless server. Is there any way to get FF to run from the command line on a server with no GUI installed?
If need be, I think we will have to setup a Desktop edition (GUI) with Apache+PHP setup on it to do what we need, but it would be nice to have it all running on server boxes.
Thanks everyone
-
This is definitely not a good way to create PDFs from PHP. There are libraries for this (i.e. FPDF).
Edit: Ok, with you comment this rules out PHP libraries. Maybe this helps? Appears to do what you want. If this still requires an X11 display set, investigate xvfb, which will create a virtual display.
Greg : None of the PHP libraries that I've explored are able to handle complex HTML-2-PDF conversion... nested tables seem to be the devil for this type of conversion. In fact, in the library you linked to had this to say in it's FAQ: # 19. Can I convert an HTML page to PDF with FPDF? Not real-world pages. But a GPL C utility does exist, htmldoc, which allows to do it and gives good results: None of the PHP libraries for doing HTML-2-PDF conversions seem to have anything close to the functionality of just doing a "Print to file"->PDF inside of the FF browser. IE has a similar feature.From SvenW -
I'd suggest wkthtmltopdf to render a html page as pdf (including stylesheets) and print it via CUPS/deliver it to the user/do whatever you want with it.
From fuero
0 comments:
Post a Comment