Jump to content

php_printer.dll problem with utf-8 or other chars like chinese & japanese


Recommended Posts

I have already asked help from google but with no solution.

 

So i am resorting to asking help from you guys.

 

I have no problem printing regular ASCII characters on a network printer,

 

i am just really having problem printing Chinese, Japanese, Arabic, UTF-8 characters.

 

i almost tried everything i could find on google even playing with the mbstring settings.

 

Below is the code i use to test my server printing.

 

 

$sText = '測試 test'; <-- Aw! This site does not support utf-8, preview post shows what i see on my printout, hahaha, please try using translate.google for the testing if you can. Still, thank you phpfreaks.com for letting me ask for help.

$rHandle = printer_open('BGP02');

$rFont = printer_create_font('Consolas', 20, 10, 100, false, false, false, 0);

 

printer_set_option($rHandle, PRINTER_MODE, 'TEXT');

printer_start_doc($rHandle, "My Queue");

printer_start_page($rHandle);

printer_select_font($rHandle, $rFont);

printer_draw_text($rHandle, $sText, 0, 0);

printer_delete_font($rFont);

printer_end_page($rHandle);

printer_end_doc($rHandle);

printer_close($rHandle);

 

 

 

 

There are a few things I can think of that might be the cause of the issue:

  • The font you've selected is not UTF-8 compatible.
  • The TEXT mode might support only ASCII characters, which means you'll probably have to use one of the other options.
  • There's also a note on the manual page for printer_set_option () about a bug. It's from 2009, so not sure if it's still valid.
  • You might have to use postscript to communicate with the server. Most likely this will require "RAW" instead of "TEXT"

 

PS: Please use the


tags around your code, as it helps make both your post and your code a lot easier to read.

Hi Christian,

 

 

Thanks for the suggestions but i am still having the same problem.

 

I tried a font face i got from another site. I am on the verge of banging my head.  :D

 

Anybody who got a solution for this, i really need help. Cheers!

 

<?php

$sText   = '測試 test';
$rHandle   = printer_open('BGP02');
$rFont   = printer_create_font('新細明體', 20, 10, 100, false, false, false, 0);

printer_set_option($rHandle, PRINTER_MODE, 'RAW');   
printer_start_doc($rHandle, "My Queue");
printer_start_page($rHandle);
printer_select_font($rHandle, $rFont);
printer_draw_text($rHandle, $sText, 0, 0);
printer_delete_font($rFont);
printer_end_page($rHandle);
printer_end_doc($rHandle);
printer_close($rHandle);

?>

This site automatically parse my code please replace two of the lines with the two below

 

$sText  = '測試 test';

 

$rFont  = printer_create_font('新細明體', 20, 10, 100, false, false, false, 0);

Have you verified that the $rFont result is a resource, and not false? Also, tried my last suggestion from my previous post?

You might need to ask the company that made the printer, they should be more familiar with its capabilities after all.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.