mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-09 11:08:34 +01:00
70 lines
2.3 KiB
PHP
70 lines
2.3 KiB
PHP
<?php
|
|
require_once(dirname(__FILE__) . "/../../Escpos.php");
|
|
$profile = DefaultCapabilityProfile::getInstance();
|
|
// This is a quick demo of currency symbol issues in #39.
|
|
|
|
/* Option 1: Native ESC/POS characters, depends on printer and is buggy. */
|
|
$connector = new FilePrintConnector("php://stdout");
|
|
$printer = new Escpos($connector, $profile);
|
|
$printer -> text("€ 9,95\n");
|
|
$printer -> text("£ 9.95\n");
|
|
$printer -> text("$ 9.95\n");
|
|
$printer -> text("¥ 9.95\n");
|
|
$printer -> cut();
|
|
$printer -> close();
|
|
|
|
/* Option 2: Image-based output (formatting not available using this output). */
|
|
$buffer = new ImagePrintBuffer();
|
|
$connector = new FilePrintConnector("php://stdout");
|
|
$printer = new Escpos($connector, $profile);
|
|
$printer -> setPrintBuffer($buffer);
|
|
$printer -> text("€ 9,95\n");
|
|
$printer -> text("£ 9.95\n");
|
|
$printer -> text("$ 9.95\n");
|
|
$printer -> text("¥ 9.95\n");
|
|
$printer -> cut();
|
|
$printer -> close();
|
|
|
|
/*
|
|
Option 3: If the printer is configured to print in a specific code
|
|
page, you can set up a CapabilityProfile which either references its
|
|
iconv encoding name, or includes all of the available characters.
|
|
|
|
Here, we make use of CP858 for its inclusion of currency symbols which
|
|
are not available in CP437. CP858 has good printer support, but is not
|
|
included in all iconv builds.
|
|
*/
|
|
class CustomCapabilityProfile extends SimpleCapabilityProfile {
|
|
function getCustomCodePages() {
|
|
/*
|
|
* Example to print in a specific, user-defined character set
|
|
* on a printer which has been configured to use i
|
|
*/
|
|
return array(
|
|
'CP858' => "ÇüéâäàåçêëèïîìÄÅ" .
|
|
"ÉæÆôöòûùÿÖÜø£Ø×ƒ" .
|
|
"áíóúñѪº¿®¬½¼¡«»" .
|
|
"░▒▓│┤ÁÂÀ©╣║╗╝¢¥┐" .
|
|
"└┴┬├─┼ãÃ╚╔╩╦╠═╬¤" .
|
|
"ðÐÊËÈ€ÍÎÏ┘┌█▄¦Ì▀" .
|
|
"ÓßÔÒõÕµþÞÚÛÙýݯ´" .
|
|
" ±‗¾¶§÷¸°¨·¹³²■ ");
|
|
}
|
|
|
|
function getSupportedCodePages() {
|
|
return array(
|
|
0 => 'custom:CP858');
|
|
}
|
|
}
|
|
|
|
$connector = new FilePrintConnector("php://stdout");
|
|
$profile = CustomCapabilityProfile::getInstance();
|
|
$printer = new Escpos($connector, $profile);
|
|
$printer -> text("€ 9,95\n");
|
|
$printer -> text("£ 9.95\n");
|
|
$printer -> text("$ 9.95\n");
|
|
$printer -> text("¥ 9.95\n");
|
|
|
|
$printer -> cut();
|
|
$printer -> close();
|