Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
979 views
in Technique[技术] by (71.8m points)

php - Call to undefined function printer_open()

I am trying to connect to my printer which is on another machine through this code

     $handle = printer_open("\\xxx.xxx.xxx.xxx\Canon MF4320-4350");
     if($handle)
     echo "connected";
     else
     echo "not connected";     

and getting the error

    Fatal error: Call to undefined function printer_open() in C:wampwwwprintindex.php on line 3

I have installed the php_printer.dll but it is not showing it under phpinfo(). Using PHP version 5.3.0

how can i connect to the printer and make my printer_open() method work??

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you are using PHP 5.3/ 5.4/ 5.5 in WAMP, here is how you setup printer.

  1. Go to this link:http://windows.php.net/downloads/pecl/snaps/printer/0.1.0-dev/
  2. Download the zip for your version. First try with ts. If it does not work, try nts.
  3. Unzip and copy the php_printer.dll file. Paste here: C:wampinphp(phpyourversion)ext . Note: (phpyourversion) will be like php5.5.12 depending on your version.
  4. Find the loaded php.ini file. Use phpinfo or Wamp menu to find it. Look online for more help.
  5. Paste this at the end of the file: extension=php_printer.dll
  6. Restart server.
  7. Create a file with the following code and test it:

    <?php
    $printer_name = "Your Printer Name exactly as it is"; $handle = printer_open($printer_name); printer_start_doc($handle, "My Document"); printer_start_page($handle); $font = printer_create_font("Arial", 100, 100, 400, false, false, false, 0); printer_select_font($handle, $font); printer_draw_text($handle, 'This sentence should be printed.', 100, 400); printer_delete_font($font); printer_end_page($handle); printer_end_doc($handle); printer_close($handle);

  8. If the above does not work, try with nts version of the php_printer.dll file as mentioned in step two. remember to restart server after deleting the previous file, pasting the new file.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...