From d627fa8f6bf7742613cf7c50aa1dfb43a59c2fbc Mon Sep 17 00:00:00 2001 From: Muraveiko Date: Sat, 28 Sep 2019 12:08:07 +0300 Subject: [PATCH 1/3] RawBT Integration Demo --- example/README.md | 2 +- example/rawbt-receipt.html | 33 +++++ example/rawbt-receipt.php | 140 ++++++++++++++++++ example/resources/rawbtlogo.png | Bin 0 -> 1573 bytes .../PrintConnectors/RawbtPrintConnector.php | 77 ++++++++++ 5 files changed, 251 insertions(+), 1 deletion(-) create mode 100644 example/rawbt-receipt.html create mode 100644 example/rawbt-receipt.php create mode 100644 example/resources/rawbtlogo.png create mode 100644 src/Mike42/Escpos/PrintConnectors/RawbtPrintConnector.php diff --git a/example/README.md b/example/README.md index 68b0dc77..dbf687d6 100644 --- a/example/README.md +++ b/example/README.md @@ -23,4 +23,4 @@ Each example prints to standard output, so either edit the print connector, or r - `print-from-html.php` - Runs `wkhtmltoimage` to convert HTML to an image, and then prints the image. (This is very slow) - `character-tables.php` - Prints a compact character code table for each available character set. Used to debug incorrect output from `character-encodings.php`. - `print-from-pdf.php` - Loads a PDF and prints each page in a few different ways (very slow as well) - +- `rawbt-receipt` (.php & .html) - Back and Front demo integrate with "RawBT - Printer driver for Android" diff --git a/example/rawbt-receipt.html b/example/rawbt-receipt.html new file mode 100644 index 00000000..c11a5ba0 --- /dev/null +++ b/example/rawbt-receipt.html @@ -0,0 +1,33 @@ + + + + + RawBT Integration Demo + + + + + + + +

RawBT Integration Demo

+ +

Example

+

+ + diff --git a/example/rawbt-receipt.php b/example/rawbt-receipt.php new file mode 100644 index 00000000..78c69519 --- /dev/null +++ b/example/rawbt-receipt.php @@ -0,0 +1,140 @@ +getSupportsGraphics()){ + $printer -> graphics($logo); +} +if($profile->getSupportsBitImageRaster() && !$profile->getSupportsGraphics()){ + $printer -> bitImage($logo); +} + +/* Name of shop */ +$printer -> setJustification(Printer::JUSTIFY_CENTER); +$printer -> selectPrintMode(Printer::MODE_DOUBLE_WIDTH); +$printer -> text("ExampleMart Ltd.\n"); +$printer -> selectPrintMode(); +$printer -> text("Shop No. 42.\n"); +$printer -> feed(); + + +/* Title of receipt */ +$printer -> setEmphasis(true); +$printer -> text("SALES INVOICE\n"); +$printer -> setEmphasis(false); + +/* Items */ +$printer -> setJustification(Printer::JUSTIFY_LEFT); +$printer -> setEmphasis(true); +$printer -> text(new item('', '$')); +$printer -> setEmphasis(false); +foreach ($items as $item) { + $printer -> text($item->getAsString(32)); // for 58mm Font A +} +$printer -> setEmphasis(true); +$printer -> text($subtotal->getAsString(32)); +$printer -> setEmphasis(false); +$printer -> feed(); + +/* Tax and total */ +$printer -> text($tax->getAsString(32)); +$printer -> selectPrintMode(Printer::MODE_DOUBLE_WIDTH); +$printer -> text($total->getAsString(32)); +$printer -> selectPrintMode(); + +/* Footer */ +$printer -> feed(2); +$printer -> setJustification(Printer::JUSTIFY_CENTER); +$printer -> text("Thank you for shopping\n"); +$printer -> text("at ExampleMart\n"); +$printer -> text("For trading hours,\n"); +$printer -> text("please visit example.com\n"); +$printer -> feed(2); +$printer -> text($date . "\n"); + +/* Barcode Default look */ + +$printer->barcode("ABC", Printer::BARCODE_CODE39); +$printer -> feed(); +$printer -> feed(); + + +// Demo that alignment QRcode is the same as text +$printer2 = new Printer($connector); // dirty printer profile hack !! +$printer2 -> setJustification(Printer::JUSTIFY_CENTER); +$printer2 -> qrCode("https://rawbt.ru/mike42",Printer::QR_ECLEVEL_M, 8); +$printer2 -> text("rawbt.ru/mike42\n"); +$printer2 -> setJustification(); +$printer2 -> feed(); + + +/* Cut the receipt and open the cash drawer */ +$printer -> cut(); +$printer -> pulse(); + +$printer -> close(); + +/* A wrapper to do organise item names & prices into columns */ +class item +{ + private $name; + private $price; + private $dollarSign; + + public function __construct($name = '', $price = '', $dollarSign = false) + { + $this -> name = $name; + $this -> price = $price; + $this -> dollarSign = $dollarSign; + } + + public function getAsString($width=48) + { + $rightCols = 10; + $leftCols = $width-$rightCols; + if ($this -> dollarSign) { + $leftCols = $leftCols / 2 - $rightCols / 2; + } + $left = str_pad($this -> name, $leftCols) ; + + $sign = ($this -> dollarSign ? '$ ' : ''); + $right = str_pad($sign . $this -> price, $rightCols, ' ', STR_PAD_LEFT); + return "$left$right\n"; + } + + public function __toString(){ + return $this->getAsString(); + } + +} diff --git a/example/resources/rawbtlogo.png b/example/resources/rawbtlogo.png new file mode 100644 index 0000000000000000000000000000000000000000..368673511a850d3cec1d05ccfca3cc2b2a6f979f GIT binary patch literal 1573 zcmV+=2HN?FP)7DVZTk zoLNB6$PBHuGj@g`aX~sYp+soyMNcRZf(lEYPACzYTT$amgyup$u0&{yHm*eQDy*zi z!%BpfRw8r+8&)E8Rt+l=I&w_`TbehcR`J04gi))&CKhi2`7p4#33WA4 z4_XC!diTJ?RTT90u>L!h)@2Pfbb*$Yho}QPYG<|405&~MRf)0!?3@M7hKPNjVM9b% z7uZ=KzZzH|!lI+j*~+}cw1hqc6b(z2fSveMb}Lm88hUP6^;1(8`T(%1lj0UvpqvEi z(iXw8X`m;HQDDPSb#7=d-H6Bu_Tm=nF8qN=Te{;w?tpAPiYw6jZ`#v=?pFq@r>X*wms-MO zK+ymuEg`65z##IfLo9OI5*`8S4Je#7`2G?^qir3iez~?THJcun?W}COx{cWv(#Ep@ z%p7yu%jdFknW>le!u|S*qK;?)^Nz9SS)>okfq7i-0ZFHr0SlK8=0F;Yz%+X4JZ5%* zxX;Oeg)1coT#c)oakVpdvB%7Sg*@Sat8RQu@Scd(#1YUQ1qv5rwj)EMUKhx!K4n7MvwRfzm3<=x_#SPvEC9nFd9|RzKo;VmAmJ$jW1_1AH3G_be~rbA zv*XRatlf1GAdfi(pVgqC@W)cBECE@}db$G?$AB`d8V8CRFu#@?1%8zJ{>y>t95BmW zq##j~KysTg3RFEHy8@^yKsE$4RUrSNfd&E1e+;x$AiEN%5l{~T)g+KUXJaLxN`Nxf zv^mh=WTs=d!az0x)GV3eV?J2@u}4${TsGSQlJLX`uyhZKfqRl6zz=e1gOUi4t1$!= zE_ZQwh7WU;+#0(leoC)`!iT_T_;0YwLR zOWRcug0PmeKzSt)sNZZXKS$efAOrZ7m>C2AnFGF)_Gz0JOgRC3z&$<6D638YUjSc_ znJ)qUM1fgpJq&!K;Sfjg^FVzXXaNBE%>}?m87R*I`L#ggH|jj_N&H69G(HcM1o(Cm zi2P>b{SmY}kpetWP~ewwpcWqZf@tQ~eVeu_p#c=dG^)4bqU&C`42c6b8NF!YcoE9ds`j)2c! zb~8WVXTL+pOK4FpICr3qKqsjKI_o0ORCS<84_5$MxVevi^Zp0$R}PdtAdkSu&24)J zK5xNobsZ>^0EK|hdlhKXsy;M6EX^7MP=BNYP&lBf14VjswC}hCR4H(q{gv2Mre6+L zq49~=jAjG<4eq(@^B#f914Yo7G|649j*X91A<8(%HqJ=*cr&`r#*gm|i=6;bqHtf+ zBF+9H>Zb=<5oZhXoidSs{mknavK!>r&AqO`q2X)>)z2UAc4pLp@S_7?VE=c(+Z^ya XlC;yvH;PRH00000NkvXXu0mjfk#^1R literal 0 HcmV?d00001 diff --git a/src/Mike42/Escpos/PrintConnectors/RawbtPrintConnector.php b/src/Mike42/Escpos/PrintConnectors/RawbtPrintConnector.php new file mode 100644 index 00000000..2aaa0f2a --- /dev/null +++ b/src/Mike42/Escpos/PrintConnectors/RawbtPrintConnector.php @@ -0,0 +1,77 @@ + buffer = []; + } + + public function clear() + { + $this -> buffer = []; + } + + public function __destruct() + { + if ($this -> buffer !== null) { + trigger_error("Print connector was not finalized. Did you forget to close the printer?", E_USER_NOTICE); + } + } + + public function finalize() + { + ob_end_clean(); + echo "intent:base64,".base64_encode($this -> getData())."#Intent;scheme=rawbt;package=ru.a402d.rawbtprinter;end;"; + $this -> buffer = null; + } + + /** + * @return string Get the accumulated data that has been sent to this buffer. + */ + public function getData() + { + return implode($this -> buffer); + } + + /** + * {@inheritDoc} + * @see PrintConnector::read() + */ + public function read($len) + { + return $len >= strlen($this -> readData) ? $this -> readData : substr($this -> readData, 0, $len); + } + + public function write($data) + { + $this -> buffer[] = $data; + } +} From b009b04af86cb41b4639485d8efd41b7be0c9b99 Mon Sep 17 00:00:00 2001 From: Muraveiko Date: Sat, 28 Sep 2019 19:15:04 +0300 Subject: [PATCH 2/3] Brought beauty --- example/README.md | 2 +- example/rawbt-receipt.html | 81 +++++-- example/rawbt-receipt.php | 221 +++++++++--------- example/resources/rawbtlogo.png | Bin 1573 -> 1358 bytes .../PrintConnectors/RawbtPrintConnector.php | 40 ++-- 5 files changed, 198 insertions(+), 146 deletions(-) diff --git a/example/README.md b/example/README.md index dbf687d6..e59e6c09 100644 --- a/example/README.md +++ b/example/README.md @@ -23,4 +23,4 @@ Each example prints to standard output, so either edit the print connector, or r - `print-from-html.php` - Runs `wkhtmltoimage` to convert HTML to an image, and then prints the image. (This is very slow) - `character-tables.php` - Prints a compact character code table for each available character set. Used to debug incorrect output from `character-encodings.php`. - `print-from-pdf.php` - Loads a PDF and prints each page in a few different ways (very slow as well) -- `rawbt-receipt` (.php & .html) - Back and Front demo integrate with "RawBT - Printer driver for Android" +- `rawbt-receipt` (.php & .html) - Demonstration of Back and Front for integration between the site and the Android application “RawBT - Printer Driver for Android” diff --git a/example/rawbt-receipt.html b/example/rawbt-receipt.html index c11a5ba0..c3d307a9 100644 --- a/example/rawbt-receipt.html +++ b/example/rawbt-receipt.html @@ -5,29 +5,72 @@ RawBT Integration Demo + + -

RawBT Integration Demo

+black & white picture +

RawBT Integration Demo

+
+
+    window.location.href = ajax_backend_data;
+
+
+
+ -

Example

-

+

Visit RawBT site

diff --git a/example/rawbt-receipt.php b/example/rawbt-receipt.php index 78c69519..45a4e8fc 100644 --- a/example/rawbt-receipt.php +++ b/example/rawbt-receipt.php @@ -1,111 +1,115 @@ getSupportsGraphics()){ - $printer -> graphics($logo); -} -if($profile->getSupportsBitImageRaster() && !$profile->getSupportsGraphics()){ - $printer -> bitImage($logo); -} + /* Print top logo */ + if ($profile->getSupportsGraphics()) { + $printer->graphics($logo); + } + if ($profile->getSupportsBitImageRaster() && !$profile->getSupportsGraphics()) { + $printer->bitImage($logo); + } -/* Name of shop */ -$printer -> setJustification(Printer::JUSTIFY_CENTER); -$printer -> selectPrintMode(Printer::MODE_DOUBLE_WIDTH); -$printer -> text("ExampleMart Ltd.\n"); -$printer -> selectPrintMode(); -$printer -> text("Shop No. 42.\n"); -$printer -> feed(); - - -/* Title of receipt */ -$printer -> setEmphasis(true); -$printer -> text("SALES INVOICE\n"); -$printer -> setEmphasis(false); - -/* Items */ -$printer -> setJustification(Printer::JUSTIFY_LEFT); -$printer -> setEmphasis(true); -$printer -> text(new item('', '$')); -$printer -> setEmphasis(false); -foreach ($items as $item) { - $printer -> text($item->getAsString(32)); // for 58mm Font A -} -$printer -> setEmphasis(true); -$printer -> text($subtotal->getAsString(32)); -$printer -> setEmphasis(false); -$printer -> feed(); - -/* Tax and total */ -$printer -> text($tax->getAsString(32)); -$printer -> selectPrintMode(Printer::MODE_DOUBLE_WIDTH); -$printer -> text($total->getAsString(32)); -$printer -> selectPrintMode(); - -/* Footer */ -$printer -> feed(2); -$printer -> setJustification(Printer::JUSTIFY_CENTER); -$printer -> text("Thank you for shopping\n"); -$printer -> text("at ExampleMart\n"); -$printer -> text("For trading hours,\n"); -$printer -> text("please visit example.com\n"); -$printer -> feed(2); -$printer -> text($date . "\n"); - -/* Barcode Default look */ - -$printer->barcode("ABC", Printer::BARCODE_CODE39); -$printer -> feed(); -$printer -> feed(); + /* Name of shop */ + $printer->setJustification(Printer::JUSTIFY_CENTER); + $printer->selectPrintMode(Printer::MODE_DOUBLE_WIDTH); + $printer->text("ExampleMart Ltd.\n"); + $printer->selectPrintMode(); + $printer->text("Shop No. 42.\n"); + $printer->feed(); + + + /* Title of receipt */ + $printer->setEmphasis(true); + $printer->text("SALES INVOICE\n"); + $printer->setEmphasis(false); + + /* Items */ + $printer->setJustification(Printer::JUSTIFY_LEFT); + $printer->setEmphasis(true); + $printer->text(new item('', '$')); + $printer->setEmphasis(false); + foreach ($items as $item) { + $printer->text($item->getAsString(32)); // for 58mm Font A + } + $printer->setEmphasis(true); + $printer->text($subtotal->getAsString(32)); + $printer->setEmphasis(false); + $printer->feed(); + + /* Tax and total */ + $printer->text($tax->getAsString(32)); + $printer->selectPrintMode(Printer::MODE_DOUBLE_WIDTH); + $printer->text($total->getAsString(32)); + $printer->selectPrintMode(); + + /* Footer */ + $printer->feed(2); + $printer->setJustification(Printer::JUSTIFY_CENTER); + $printer->text("Thank you for shopping\n"); + $printer->text("at ExampleMart\n"); + $printer->text("For trading hours,\n"); + $printer->text("please visit example.com\n"); + $printer->feed(2); + $printer->text($date . "\n"); + + /* Barcode Default look */ + + $printer->barcode("ABC", Printer::BARCODE_CODE39); + $printer->feed(); + $printer->feed(); // Demo that alignment QRcode is the same as text -$printer2 = new Printer($connector); // dirty printer profile hack !! -$printer2 -> setJustification(Printer::JUSTIFY_CENTER); -$printer2 -> qrCode("https://rawbt.ru/mike42",Printer::QR_ECLEVEL_M, 8); -$printer2 -> text("rawbt.ru/mike42\n"); -$printer2 -> setJustification(); -$printer2 -> feed(); - - -/* Cut the receipt and open the cash drawer */ -$printer -> cut(); -$printer -> pulse(); - -$printer -> close(); + $printer2 = new Printer($connector); // dirty printer profile hack !! + $printer2->setJustification(Printer::JUSTIFY_CENTER); + $printer2->qrCode("https://rawbt.ru/mike42", Printer::QR_ECLEVEL_M, 8); + $printer2->text("rawbt.ru/mike42\n"); + $printer2->setJustification(); + $printer2->feed(); + + + /* Cut the receipt and open the cash drawer */ + $printer->cut(); + $printer->pulse(); + +} catch (Exception $e) { + echo $e->getMessage(); +} finally { + $printer->close(); +} /* A wrapper to do organise item names & prices into columns */ + class item { private $name; @@ -114,27 +118,28 @@ class item public function __construct($name = '', $price = '', $dollarSign = false) { - $this -> name = $name; - $this -> price = $price; - $this -> dollarSign = $dollarSign; + $this->name = $name; + $this->price = $price; + $this->dollarSign = $dollarSign; } - public function getAsString($width=48) + public function getAsString($width = 48) { $rightCols = 10; - $leftCols = $width-$rightCols; - if ($this -> dollarSign) { + $leftCols = $width - $rightCols; + if ($this->dollarSign) { $leftCols = $leftCols / 2 - $rightCols / 2; } - $left = str_pad($this -> name, $leftCols) ; - - $sign = ($this -> dollarSign ? '$ ' : ''); - $right = str_pad($sign . $this -> price, $rightCols, ' ', STR_PAD_LEFT); + $left = str_pad($this->name, $leftCols); + + $sign = ($this->dollarSign ? '$ ' : ''); + $right = str_pad($sign . $this->price, $rightCols, ' ', STR_PAD_LEFT); return "$left$right\n"; - } - - public function __toString(){ - return $this->getAsString(); - } - + } + + public function __toString() + { + return $this->getAsString(); + } + } diff --git a/example/resources/rawbtlogo.png b/example/resources/rawbtlogo.png index 368673511a850d3cec1d05ccfca3cc2b2a6f979f..999abab33e236912c93d59fd032431cdcdcb26e0 100644 GIT binary patch delta 1351 zcmV-N1-Sa949*IW7=Hl+0000-Z71IV000J1OjJbx00960|E1ZV-2eap0b)x>L;#2d z9Y_EG010qNS#tmY3ljhU3ljkVnw%H_000McNliru;|UxOEEHpGu`~bx1kOoBK~z}7 z<=8vY-6j+O;3Ja>oyiKKEFqp(EnuI);X7XGWDosAHLOP)UR;MsOQM66j7#jM6lO4oZ&?q0J?#ero_rOl{Ep zaRJzd6h7N;Hh*A&=AyK>!W&PX62CyzoPkq?b-#{0-CL#l9n;5%Z!~<-~yv4?4T-w^&o}h+uEe$->zJ}1kHgKkfynlv=uCO(%emg-2*S7?B2tx~} zr?7+w>~W+5u<9Rt0CN;n9U-vCNm7MNR%L@3Kv$K0hH7rQY08ifpe->6J%XV*o9rp`g#Af<7n?g$Bft(wN93YvZ*zojF*Lw z9twED7=NdY6R6|LV7SR}3Ni0O)<7GZ4e|`J=vh+Hd+fwBw9GQYH{X~EM^;RLAlDOg z+z7p>eR8~{)B+*H{i9p${&oMdf5Z{AG|;5pKMwhr*fLCEIKh}IGt4_ucbY^5)4)ty znlq$4lwlrE9$I1MZB;vcLz%4%^)x#?G+Ya{_PlYOLc_WxY#ieXF-crifzaUP9-mq2535e|BJ}XDDxcSE%M* z&m5uX_4PG;Ps?f;J%43r!{6t6*&-OWNglEcwU3Au7jO-Ga4HlNkDkMlku!6FbC@%f zn}2XK5^j>AuAm6B&>kSWfIO7gg}AcF_c@c%c{ z^*yu|)E&6haQ@D4L%97{sB0*mL4{Ctpc%k;yrZ7MBb=Ga>MRS~aKhoXZY8L%p~5+e z8^syI2~W{fl|LOIZAx{5d6*IOQ*tBthJQ9v2nDzb{>lid6=6K=HxOGV-!VGz$|Xa7 z1>xOvf-Ki@FOL%t+7?dnbphP_VJAEI{QxKIPe*YixFY-z;F|&&jXCN<+;_%B=L58m z)5NSGCm3d`{joqnQ$50s$Mc6h!I^SQfh@xCwS8NlM>Q0>fj<|xA7DIn`Ii<>Cw~Yv ze94dqc-X@b3YPr%S)4hxB+4eFv!~Np2sh7LLL^W1j7R+o8gOxb6NJnJWeny zDh0+z6loz1(AIE@`(9Z?mY+x<48td{AZcZ7;6yN>3{?$z%yCz6i${M`_@mmY%zWJ6}KzKTuN;8(2sLQBVzp1p002ov JPDHLkV1mEgXPf{4 delta 1568 zcmV+*2H*M43Z)E?7=Ho-00000&0P-w000S4OjJd103!eZ0RR90jVmt(00001bW%=J z06^y0W&i*H0b)x>L;#2d9Y_EG1-(f`K~!ko<(fT?BqtPr-?ZeU^F4wkdro2b1P%<+ zkZ-V@qGLx+n79+HhEr};LBV_c7F5Yz$w;G~o`!FDKfE8R!G9*huw~f!0m*yCw!yCg zvVHJtfQp?aLZ-ic$P0jsjPpQ6f#NLCFm}Nfq2w`Vd7DVZTkoLNB6$PBHuGj@g`aX~sY zp+soyMNcRZf`1B2pH3(dnp;uhN`&S@J+4G(i#D!A@G7jVQ^QJxwq$x(iO|-)8CD{6 z1RGW&bXE;35jt{B0b80kqgL_2`h-!dz$O-N0r@bnxe0YOP!C!KdV2T3!&MaY_OSjt zmDXhqHFSZNm4~PUJ8EaO(Ev6*O;w4q0_>ax&4!45pnqXQL|7NtSs=d}SRlfpqt4mN zyu`GGJ_HmEOO=3~_*8Z)RS_C`ZdmnGQx^IFu&R^d7FVF01nSZj!Ln(fCyG&E!%=l^ zXfWM~+?tVha0h^Po3Z@pWu=nVaQADB_f5bMK3y9)T%dCr5&9G-Op<4iq-v> z*LC*d7Jut5{DDYYy5m6ZfNVXAE71FI+S7sVR|c!6ssfOgTEb&M(EuhbA*f@(Ao8k1 zEOOcs9s%kND4aF;{t`r^Z5^n7xwbAfn;w_#tZciwjoBB{#t=dyB{sh9V{ z{rZWbj%Wb$j4n7M zvwwUP_?3Ml1^6Cqv@8I_A9=N)!ax?{p&;QY0%M}912qE5cz=z>jI-m-zO3DK5Fn2^ z1)tTRpzz01sw@Fn%zC;56vu!vtQrT38Zf_>8wGxp`u@v->Kri3U8EpUlR$EtF$z>Y zAiDynD?l~`G*uw~p@9Yg&3_EERUo?(sDBYq4+7OBkUnQ)C7?=xGS;*?(BNdIW4OXV zHUiWvnc`zUSpBg_R0Lc$+X0gB#0ao-4~l_%k|Dqka%qE-2#~8W1Qg`oyJ`*r>D5;i zC=qaX1n-h+>mW0rJP2efkRJewT!*%F@r!`E3FP#>aJR(SedS*6w}2cSN`w6{Q-6pD z>Hz#G0tM+B(b0>3L#i3M=einDlH6DXN>Uz0;I|@>W^W8Mu8)yP{n!C=T687A-;?KD zdTU7BWX((oC~1w90KqnZya=>y;5&U}vAt^oc@y|2+*Q(DBA_S%MF)6G+f@;Qu$Hqx zc_k32-)t;DN852A1NfDg83X^B1Ao4g_Gz0JOgRC3z&$<6D638YUjSc_nJ)qUM1fgp zJq&!K;Sfjg^FVzXXaNBE%>}?m87R*I`L#ggH|jj_N&H69G(HcM1o(Cmi2P>b{SmY} zkpetWP~ewwpcWqZf@tQ~eVeu_p#c=dG^)4 z$V+HZE;x6fjzA}=13K#>&s24wNDo&4TDZB7fAjta@K+9$Js^+3$IWef2R?7XZFLlm^d, + * incorporating modifications by others. See CONTRIBUTORS.md for a full list. + * + * This software is distributed under the terms of the MIT license. See LICENSE.md + * for details. + */ namespace Mike42\Escpos\PrintConnectors; /** - * Print connector that writes to nowhere, but allows the user to retrieve the - * buffered data. Used for testing. + * Print connector for android RawBT application + * https://play.google.com/store/apps/details?id=ru.a402d.rawbtprinter */ final class RawbtPrintConnector implements PrintConnector { @@ -30,27 +34,27 @@ final class RawbtPrintConnector implements PrintConnector */ public function __construct() { - ob_start(); - $this -> buffer = []; + ob_start(); + $this->buffer = []; } public function clear() { - $this -> buffer = []; + $this->buffer = []; } - + public function __destruct() { - if ($this -> buffer !== null) { + if ($this->buffer !== null) { trigger_error("Print connector was not finalized. Did you forget to close the printer?", E_USER_NOTICE); } } public function finalize() { - ob_end_clean(); - echo "intent:base64,".base64_encode($this -> getData())."#Intent;scheme=rawbt;package=ru.a402d.rawbtprinter;end;"; - $this -> buffer = null; + ob_end_clean(); + echo "intent:base64," . base64_encode($this->getData()) . "#Intent;scheme=rawbt;package=ru.a402d.rawbtprinter;end;"; + $this->buffer = null; } /** @@ -58,7 +62,7 @@ public function finalize() */ public function getData() { - return implode($this -> buffer); + return implode($this->buffer); } /** @@ -67,11 +71,11 @@ public function getData() */ public function read($len) { - return $len >= strlen($this -> readData) ? $this -> readData : substr($this -> readData, 0, $len); + return $len >= strlen($this->readData) ? $this->readData : substr($this->readData, 0, $len); } public function write($data) { - $this -> buffer[] = $data; + $this->buffer[] = $data; } } From 2051e84327efbeb6a664285e645bbaf2fe92b2ac Mon Sep 17 00:00:00 2001 From: Michael Billington Date: Sat, 5 Oct 2019 14:48:54 +1000 Subject: [PATCH 3/3] list printers tested since previous release --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 17acf9f1..c5bb5c91 100644 --- a/README.md +++ b/README.md @@ -75,13 +75,16 @@ Many thermal receipt printers support ESC/POS to some degree. This driver has be - Bematech LR2000E - Birch PRP-085III - Bixolon SRP-350III +- Bixolon SRP-350Plus - Black Copper BC-85AC +- CHD TH-305N - Citizen CBM1000-II - Citizen CT-S310II - Dapper-Geyi Q583P - Daruma DR800 - DR-MP200 (manufacturer unknown) - EPOS TEP 220M +- Elgin i9 - Epson EU-T332C - Epson FX-890 (requires `feedForm()` to release paper). - Epson TM-T20 @@ -98,9 +101,11 @@ Many thermal receipt printers support ESC/POS to some degree. This driver has be - Epson TM-U295 (requires `release()` to release slip). - Epson TM-U590 and TM-U590P - Equal (EQ-IT-001) POS-58 +- Everycom EC-58 - Excelvan HOP-E200 - Excelvan HOP-E58 - Excelvan HOP-E801 +- Gainscha GP-2120TF - Gainscha GP-5890x (Also marketed as EC Line 5890x) - Gainscha GP-U80300I (Also marketed as gprinter GP-U80300I) - gprinter GP-U80160I @@ -122,9 +127,13 @@ Many thermal receipt printers support ESC/POS to some degree. This driver has be - Rongta RP326US - Rongta RP58-U - Rongta RP80USE +- SAM4S GIANT-100DB - Senor TP-100 - Sewoo SLK-TS400 +- SEYPOS PRP-96 - SEYPOS PRP-300 (Also marketed as TYSSO PRP-300) +- SNBC BTP-R880NPIII +- Solux SX-TP-88300 - Sicar POS-80 - Silicon SP-201 / RP80USE - SPRT SP-POS88V @@ -133,6 +142,7 @@ Many thermal receipt printers support ESC/POS to some degree. This driver has be - Star TSP100III FuturePRNT - Star TSP-650 - Star TUP-592 +- TVS RP45 Shoppe - Venus V248T - Xeumior SM-8330 - Xprinter F-900 @@ -146,6 +156,7 @@ Many thermal receipt printers support ESC/POS to some degree. This driver has be - Zjiang ZJ-5870 - Zjiang ZJ-5890 (Also sold as POS-5890 by many vendors; ZJ-5890K, ZJ-5890T also work). - Zjiang ZJ-8220 (Also marketed as Excelvan ZJ-8220) +- Zjiang ZJ-8250 If you use any other printer with this code, please [let us know](https://github.com/mike42/escpos-php/issues/new) so that it can be added to the list.