mike42 / escpos-php

PHP library for printing to ESC/POS-compatible thermal and impact printers
Other
2.58k stars 863 forks source link

Arabic lettres printing issues #1147

Open abdellahFromMorocco opened 2 years ago

abdellahFromMorocco commented 2 years ago

Hi Mike I hope that you are doing good :) ,

I'm using the Escpos libraries in a PHP programm to print a ticket in arabic letters using PHP 7 with imagick onwindows 7 (32 bits) and using Rongta printer. that is works perfectly ,my ticket printed correctly in arabic text.

Today I'm working with same php programme using a diffrent environment : PHP 8 , on winodows 7 ( 64bits) with another printer GPrinter (GP-C80250l plus).the probelme that I'm facing today that my programm prints arabic letter but left to right and not on connected way !(see below example)

image

I tried to print same arabic text from miscroft word and using the same machine (PHP 8 , on winodows 7 ( 64bits) with GPrinter (GP-C80250l plus)) and that is working fine (see below creen)

image

do you have any idea how I can resolve this issue ? thank you for your help. below is my PHP code :

require DIR . '/../../autoload.php'; use Mike42\Escpos\CapabilityProfile; use Mike42\Escpos\Printer; use Mike42\Escpos\EscposImage; use Mike42\Escpos\PrintConnectors\FilePrintConnector; use Mike42\Escpos\PrintConnectors\WindowsPrintConnector; use Mike42\Escpos\PrintBuffers\ImagePrintBuffer; require_once(dirname(FILE) . "/../../I18N/Arabic.php"); $fontPath = dirname(FILE) . "/../../I18N/Arabic/Examples/GD/ae_AlHor.ttf";

$maxChars = 50; $fontSize = 30;

mb_internal_encoding("UTF-8"); $Arabic = new I18N_Arabic('Normalise');

$textUtf8 = "شارع المنظر العام ،قيسارية المنظر العام باب -07- رقم 29 عين الشق البيضاء ";

$textLtr = $Arabic -> utf8Glyphs($textUtf8, $maxChars); $textLine = explode("\n", $textLtr); $buffer = new ImagePrintBuffer(); $buffer -> setFont($fontPath); $buffer -> setFontSize($fontSize); $profile = CapabilityProfile::load("TEP-200M"); $connector = new WindowsPrintConnector("RONGTA80mm"); $printer = new Printer($connector,$profile ); $printer -> setPrintBuffer($buffer); $printer -> setJustification(Printer::JUSTIFY_CENTER);

foreach($textLine as $text) { $printer -> text($text . "\n"); } $printer -> cut(); $printer -> close();

abdellahFromMorocco commented 2 years ago

hello All,

I had some doubt related to the printer (GPrinter model) and I have tested the same printer used in my first environment which working fine (Rongta ) and I had the same result (Arabic letterx are printed left to right and not connected) so the probleme is not coming from Printer!

Another remark , in the previous environment which is working fine ,my ticket takes around 10 seconds to be generated and this related to my program which is using imagick (this not imapcting as i m not printing more that 10 ticket per day).Now in the new environment the ticket is printed quickly .there is two hypothesis my new machin has more perfomance than the old one ATOM VS I5 or may be the imagick library is not working as expected!

Best regards. Abdellah.

SalimF commented 2 years ago

Can anyone solved this, I don't mind if I just had to send image from Ar-PHP like this image to escpos-php to print it correctly .

image

I just the print to be clear( readable )