当前位置:首页>开发>正文

php怎么调用指定的打印机 打印机调用哪几个api函数来打印数据

2023-07-07 10:49:52 互联网 未知 开发

 php怎么调用指定的打印机 打印机调用哪几个api函数来打印数据

php怎么调用指定的打印机

php生成的是网页吧,然后用ie浏览,在ie上有个打印按钮,可以选择打印机
但ie不是你用php写的,是微软写的
你怎么控制一个微软写的软件,并使用它选择打印机?除非他提供了接口
微软是否提供了接口,应该没有,否则早有人回帖了
但还有一个可能,当你改变本机 打印机的首选项时,有可能记录在注册表里面。如果是这样,那就直接改变注册表,就相当于选择了打印机
但是你想,当你浏览一个网页,它会修改你的注册表,这让人放不放心,算不算病毒,会不会被杀毒软件屏蔽?或者根本通不过ie默认的安全选项
最终结局就是,b/s方式不要想控制客户的硬件
但我还是要打印,在当前,只有让客户安装打印控件,这样才可能让客户自定义打印机相关
还有一种想法,不用客户端控制来打印,把打印要求提交到服务器,让服务器选择打印机,没有用过,你不如研究一下?

另外php最多只能控制服务器的硬件,想控制客户机最多只能用js
对客户机某些打印选项的注册表操作,下面有js的例子用法,很久以前的,仅做参考


var hkey_root,hkey_path,hkey_key
hkey_root="HKEY_CURRENT_USER"
hkey_path="\Software\Microsoft\Internet Explorer\PageSetup\"
//设置网页打印的页眉页脚为空
function pagesetup_null(){
try{
var RegWsh = new ActiveXObject("WScript.Shell")
hkey_key="header"
RegWsh.RegWrite(hkey_root hkey_path hkey_key,"")
hkey_key="footer"
RegWsh.RegWrite(hkey_root hkey_path hkey_key,"")
hkey_key="margin_left"
RegWsh.RegWrite(hkey_root hkey_path hkey_key,"0.2")
hkey_key="margin_bottom"
RegWsh.RegWrite(hkey_root hkey_path hkey_key,"0.2")
hkey_key="margin_right"
RegWsh.RegWrite(hkey_root hkey_path hkey_key,"0.2")
hkey_key="margin_top"
RegWsh.RegWrite(hkey_root hkey_path hkey_key,"0.2")
}catch(e){}
}
//设置网页打印的页眉页脚为默认值
function pagesetup_default(){
try{
var RegWsh = new ActiveXObject("WScript.Shell")
hkey_key="header"
RegWsh.RegWrite(hkey_root hkey_path hkey_key,"&w&b页码,&p/&P")
hkey_key="footer"
RegWsh.RegWrite(hkey_root hkey_path hkey_key,"&u&b&d")
}catch(e){}
}


打印分页

page1


page2

打印机调用哪几个api函数来打印数据

在MSDN库中去找。取一个函数名拷贝到MSDN的关键字栏里搜索就出来了,而且有详细的参数解释及用法。如:EndPagePrinter

BOOL EndPagePrinter(
HANDLE hPrinter // handle to printer object
)

Parameters

hPrinter
[in] Handle to the printer for which the page will be concluded. Use the OpenPrinter or AddPrinter function to retrieve a printer
handle.

Return Values

If the function succeeds, the return value is a nonzero value.

If the function fails, the return value is zero. To get extended error
information, call GetLastError.

Remarks

Each page in a print job begins with a StartPagePrinter function call and ends with
an EndPagePrinter function call. The data for each page is written to the
print file by using the WritePrinter
function.

Requirements

Windows NT/2000: Requires Windows NT 3.1 or later.
Windows
95/98: Requires Windows 95 or later.
Header: Declared in
Winspool.h include Windows.h.
Library: Use Winspool.lib.

See Also

Printing and Print Spooler Overview, Printing and Print Spooler Functions, OpenPrinter, StartPagePrinter, WritePrinter

php怎样连接热敏打印机

首先的知道你的打印机是并口还是串口。具体操作是把热敏打印机的并(串)口连接线接在电脑的后面主板的并口(串口)上,然后给打印机接上电源线搞定。
并口是电脑主板上那个最大口最多的那个,串口是COM口,一般普通电脑只有一个COM1口。

接上后向测试电脑和打印机是否连接的话,1:给打印机装纸 2:打印机自检(看看打印机是好的吗)3:进入连接电脑的DOS里面,在DOS里面回到从C盘的根目录下面即 C: 在输入DIR>LPT1 (DIR>LPT1针对并口打印机。串口的话是DIR>COM1) 回车 打印机出纸证明连接OK。

最新文章