如何在PHP-Gtk中给打印机打印? [英] How to give a print to printer in PHP-Gtk?

查看:61
本文介绍了如何在PHP-Gtk中给打印机打印?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用PHP-Gtk打印一些记录.

I want to print some records using PHP-Gtk.

我正在使用以下代码,但是没有用.

I am using following code but it did not worked.

$handle = fopen("PRN", "w"); 
fwrite($handle, 'text to printer'); 
fclose($handle);

请帮助我谢谢拉胡尔

推荐答案

假设您要在Windows环境中使用它,我想您应该看看

Asumming you are asking this for a Windows environment i think you should have a look at the printer functions on php.net

打印机功能是PECL扩展的一部分,可以从

The printer functions are part of the PECL extensions and it can be downloaded from php.net (Link goes to PECL 5.2.6 that works with PHP 5.2.11)

PHP中的打印机功能对我不是很有用,因此我倾向于使用不同的技术来创建PDF,并由具有更好打印支持的默认PDF阅读器(通常是Adobe Reader)显示它.但是我可以想到某些情况,而这不是一种可以接受的行为.

The printer functions in PHP are not very useful to me, so i tend to use different techniques to create a PDF and have it displayed by the default PDF reader (usually Adobe Reader) that has so much better printing support. But i can think of cases when that is not an accepted behaviour.

来自php.net的代码示例(打印到默认打印机):

Code example from php.net (prints to default printer):

$handle = printer_open();
printer_start_doc($handle, "My Document");
printer_start_page($handle);

$font = printer_create_font("Arial", 148, 76, PRINTER_FW_MEDIUM, false, false, false, -50);
printer_select_font($handle, $font);
printer_draw_text($handle, "PHP is simply cool", 40, 40);
printer_delete_font($font);

printer_end_page($handle);
printer_end_doc($handle);
printer_close($handle);

这篇关于如何在PHP-Gtk中给打印机打印?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆