Search code examples
phpprintingutf-8arabic

Printing Arabic to network printer (PHP)


I need to print Arabic text to a network printer using PHP.

Code

$ar = "عربي";

try {
    $fp = fsockopen("10.1.10.21", 9100);
    fputs($fp, $ar);
    close($fp);
    echo 'Successfully Printed';
} catch (Exception $e) {
    echo 'Caught exception: ', $e->getMessage(), "\n";
}

However, the result is garbage, so please, I need help.


Solution

  • I fix it, I put my Arabic text in the div and then I print the div with JS by using window.print() method