exchangecore / webprint
一个PHP库,旨在直接打印到网络打印机或将相同内容输出到网页。
0.9.1-beta
2014-11-30 18:13 UTC
Requires
- php: >=5.4.0
- ext-gd: *
This package is auto-updated.
Last update: 2024-09-25 03:41:00 UTC
README
该库的目的是允许一个通用的PHP API,它可以直接打印到打印设备或将相同内容输出到其他界面,例如您的网页浏览器。
支持的打印机
- 网页浏览器
- Sato E/Pro 网络打印机
特性
- 文本输出
- 字体大小
- Code 39 条形码
- 条形码高度
- 条宽
示例用法
网页浏览器示例
<?php
$printer = new exchangecore\webprint\src\printers\WebPrinter();
$printer
->setBaseReference(0.25, 0.25, $printer::UNIT_INCHES)
->setFontSize(20)
->outputText('HELLO WORLD')
->setPosition(0, 0.25, $printer::UNIT_INCHES)
->outputCode39('*123456789*', 16, $printer::UNIT_POINT, 4)
->processCommandStack();
网络打印机示例
<?php
$printer = new exchangecore\webprint\src\printers\sato\M8400rve();
$printer
->setPaperWidth(4, $printer::UNIT_INCHES)
->setBaseReference(0.25, 0.25, $printer::UNIT_INCHES)
->setFontSize(20)
->outputText('HELLO WORLD')
->setPosition(0, 0.25, $printer::UNIT_INCHES)
->outputCode39('*123456789*', 16, $printer::UNIT_POINT, 4)
->setCopies(3);
if($printer->connect('10.1.0.49')){
if($printer->processCommandStack(false)) {
echo 'Printed Successfully';
} else {
echo 'Failed to print';
}
$printer->disconnect();
} else {
echo 'Failed to connect';
};