Printing to printers in PHP

一世执手 提交于 2019-11-28 11:46:55

i messed around with printer.dll for ages and got sick of it.

not sure if its much use, but i purchased this application http://www.coolutils.com/TotalPDFPrinter

and it lets me print pdf files from the cmd line from php, which worked well for me, but it does have a popup screen which you can only get rid of if you purchase the server version (which you will need if your apache is running as a service). obviously the non-popup version is way more expensive.

one thing i struggled with, was getting a list of printers available, so i wrote this little app in C# that spits out a list of printers as plain text, and then use php to call that and put them into a drop list on my web forms.

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing.Printing;

namespace printerlist
{
    class Program
    {
        static void Main(string[] args)
        {
            foreach (String printer in PrinterSettings.InstalledPrinters)
            {
                Console.WriteLine(printer.ToString());
            }
        }
    }
}

As far as I know, you should use php_printer.dll. Check here. Then, add the php_printer.dll extension to your php.ini. If you have done that, then...

If you qualify and put clearly the ip/route in where the printer is installed, it should do the trick. Something like printer_open('\\\\xx.x.xx.xx\\_printername_');. (Local printers wouldn't need to add the server manually, afaik)

To check for printers, try something like printer_list(PRINTER_ENUM_LOCAL | PRINTER_ENUM_SHARED). There is something like a printer.default_printer directive on php.ini, if I recall ok. Tested this quite some time ago on a php 5.x installation. Good luck.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!