开发者

Class or function to automatically generate PDF and Print

Anyone know any Javascript or PHP functio开发者_高级运维n to generate PDF and print (printer) automatically.

Excuse my ignorance, I searched on google about it and can not find sufficient documentation.

Many many Thanks Guys


What are you generating your PDF from? I presume that what you want to do is generate a PDF from e.g. a form submission, then print it on the user's computer?

You cannot print from PHP (well there are horrible ways of doing it, but don't) but I doubt it would help you even if you could - it would be printed on the server side, and I imagine you would be wanting to print on the client (i.e. browser) computer.

You can generate PDF's in PHP (have a look at FPDF) and send them to the browser, and you can print a web page in javascript, but to combine the two would be tricky, if it is possible at all. You certainly can't do it without prompting the user.

If you were to generate the PDF, then open it in an iframe, you could maybe call something through javascript to prompt the user with the standard printing options dialog, but that would be as far as it goes. It wouldn't work everywhere, if it worked anywhere, which I somehow doubt.


to create PDFs, theres the great FPDF-library.

printing automatically fortunately isn't possible - just imagine this would be possible and every f***g website could (in addition to the annoying popups and stuff) print out something (advertisements most of the time) on your printer.

EDIT :
if you have control over the clients, you could write a little batch-script like (not tested)

AcroRd32.exe /t %1 printername

and then set pdf-files in your browser to open automatically with this "programm" wich should then print the file without a print-dialogue.

note that you need access to the clients for this and it isn't tested. in theory this works: i did something very similar once to print out labels directly from the browser, but this was a few years ago using WinXP, don't know if this still works on Win7 (or whatever you're using).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜