Java PrintService printing Chinese/Japanese characters output is garbled.

Hi Java Gurus,
I have been spending the whole day trying to make our text printing application able to print non-western Characters (e.g. Chinese and Japanese) as part of our requirements. But I am constantly getting garbled output when I print a UTF-8 formatted text file containing Chinese characters. I've been trying to switch the DocFlavor types (e.g. byte array in UTF 8, input stream auto sense, UT8-8, etc) but I couldn't simply make it work.
Here is our test method:
     public void testPrintText(String fileName) throws Exception {
          FileInputStream textStream = new FileInputStream(fileName);
          File file = new File(fileName);
          String fileContent = FileUtils.readFileToString(file);
          DocFlavor flavor = DocFlavor.BYTE_ARRAY.TEXT_PLAIN_UTF_8;
          //DocFlavor flavor = DocFlavor.READER.TEXT_PLAIN;
          InputStreamReader isr = new InputStreamReader(textStream, "utf-8");
          DocAttributeSet das = new HashDocAttributeSet();
          //System.out.println("host encoding: " + flavor.hostEncoding);
          Doc mydoc = new SimpleDoc(fileContent.getBytes("utf-8"), flavor, das);
          //Doc mydoc = new SimpleDoc(textStream, flavor, das);
          PrintRequestAttributeSet pas = new HashPrintRequestAttributeSet();
          pas.add(new PrinterName("\\\\fsinec\\Canon iR5055 PCL6", null));
          PrintService[] services = PrintServiceLookup.lookupPrintServices(flavor, pas);
          PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
          System.out.println("DEBUG: " + defaultService.getClass().getName());
          if(services.length == 0) {       
               if(defaultService == null) {
                    //no printer found
               } else {            
                    //print using default
                    DocPrintJob job = defaultService.createPrintJob();
                    job.print(mydoc, pas);
          } else {        
               //built in UI for printing you may not use this
               PrintRequestAttributeSet attSet = new HashPrintRequestAttributeSet();
               for(int ctr=0; ctr<services.length; ctr++) {
                    PrintService printService = services[ctr];
                    System.out.println("COTS DEBUG: " + defaultService.getClass().getName());
               //attSet.add();
               PrintService service = null;
               if(services.length == 1) {
                    //assume that there is no other printer with the name \\\\fsinec\\Canon iR5055 PCL6
                    //resulting to fetch the printer services to only one (1) element.
                    service = services[0];
               /* open a dialog box
               * PrintService service =
                    ServiceUI.printDialog(null, 200, 200, services, defaultService, flavor, attSet);*/
               if (service != null) {           
                    DocPrintJob job = service.createPrintJob();
                    job.print(mydoc, attSet);
Please help me on this.
Thanks.

This could be of different reeasons...
1) Make sure your printer is uni-code enabled.
2) Make sure, your unicode enabled printer is configured in SAP.
3) make sure, your printer device is supported by SAP. (You can find list of SAP recommended printers in www.service.sap.com)
4) Check whether the correct device type is used for printing chinese and japanese characters.
5) Check code pages.
6) Make sure you use Cyrillic font family, for printing chinese and Japanese characters.
Regards,
SaiRam

Similar Messages

  • Chinese/Japanese characters not appearing on smartforms PDF output

    Hi,
    The print preview of the Smartforms output layout is correctly displaying the characters of native/local languages like Chinese, Japanses etc.....but when i try to print this output, it is printing the junk characters.
    Whereas the same printer is able to print the Chinese, Japanese characters when printed from MS Word.
    So this issue is occurring only when printing from SAP.
    In spool i could see the Chinese/Japanese characters appearing correctly, whereas when i try to convert it to PDF using program RSTXPDFT4, the PDF is again showing junk characters replacing the chinese characters.
    Thanks!

    This could be of different reeasons...
    1) Make sure your printer is uni-code enabled.
    2) Make sure, your unicode enabled printer is configured in SAP.
    3) make sure, your printer device is supported by SAP. (You can find list of SAP recommended printers in www.service.sap.com)
    4) Check whether the correct device type is used for printing chinese and japanese characters.
    5) Check code pages.
    6) Make sure you use Cyrillic font family, for printing chinese and Japanese characters.
    Regards,
    SaiRam

  • How Oracle tables can be used to display Chinese/Japanese characters

    If anyone knows how to display Chinese/Japanese characters from Oracle tables please reply this email. Thanks.
    Regards,
    Preston

    hi
    ->Also please let me know how the Oracle Lite is licenced if I have 300 odd users of this offline applications
    you should speak to your local oracle rep about that, for us for example they gave a pretty cheap packet for olite 10gr3+ 11g repository
    ->need to use only database part of Oracle Lite and not mobile server.
    you cant do that. mobile server is the application server that handles the synchronization process from the server side. when a client tries to sync he actually connects to the mobile server and asks for the database changes , the mobile server know what the client must get so he packs it and give it to him
    ->you can ofc make lightweight .net apps using olite. we make olite apps even for wince handhelds. so yes ofcourse you can. olite had a win32 client also.
    ->can it run from usb.
    ok here to be honest ive never tried that myself, looks kinda weird as a requirement to be honest but i dont see why it shouldnt run. if you set up the paths correctly you shouldnt have a problem i think.
    ->offline application will have more or less similar data entry forms and storage structure
    yes ofcourse , if i have 3 tables in server i can choose to have 2(or all ) of them on the client too. i can even separate which client gets what. for instance if client a sells houses in new york he will get only the house table rows for new york. if another sells for chicago he will get those instead and etc.
    ->all client apps are offline and sync periodically (when you choose) to the server

  • Since upgrading to 10.8.5 some of the tracks in my library are listed in chinese/japanese characters..not English!

    Since upgrading my macbook air (10.8.5) and ios7 a large number of tracks in my library are listed in chinese/japanese characters..not English! of the 670 tracks or so around 30% are now in another character set (far eastern), not English as they were. Same on my new iphone 5s.

    Strangely enough the pref file did not show up in the Preferences folder.  I don't know what this means but it could be signifigant.

  • Bringing Chinese/Japanese characters as JLabel Text

    Hi,
    In our application we are planning to implement multiple languages as labels.
    We succeded to implement French,German etc because the characters are present on keyboard and the editors support the text.
    Now we are planning to implement Chinese/Japanese. At this moment we dont know whether we can type Chinese/Japanese text through key board and whether our editor support those characters.
    Can anybody please tell me the procedure to bring Chinese/Japanese Characters as JLabel Text in Swing Application?
    Thanks in advance,
    Vattikuti

    What you wanted to do depends to a large extent on the OS... On Windows XP, install the appropriate language packs (there are several for Chinese and at least two for Japanese languages) and check it out.
    ;o)
    V.V.

  • LaserWriter II NT printing spurious Japanese characters

    Okay, this is really bizarre! Over the past few weeks, my beloved LaserWriter II NT has begun printing a couple of Japanese characters a few times on each page. They are about 2.5 inches from the left edge of the paper, and they repeat about every 4 inches down the page. They're getting darker (and therefore more obvious) as time goes on, now making the printer useless for any sort of professional communications.
    I'm guessing that this is a sign of a terminal software problem in the printer, but before I drag all 45 lbs. of it to the nearest Mac repair shop, I thought I'd ask here for ideas on what might be causing the problem and whether there's anything that can be done about it.
    Thanks!
    Patty

    If your computer already has a serial port (com:), you probably just need a cable. There are several different kinds, but if you have a meter, I or someone else can help with pin assignments.
    A serial port may have 25 pins, like a parallel port, or could have 9 pins in the same basic shape, or be a round 8 or 9 pin port, like the other one on the printer. This is the same port you would use to connect to a regular telephone modem for dial-up Internet access. If you do not have one, you would need to add a card.
    You will also have to specify the way the port is to work: its speed, number of data bits, parity, and number of stop bits. There may be a control panel for this.
    The Centronics-style connectors in general, and the Centronics-50 in particular (used on external SCSI drives) were not invented by Centronics. [Centronics made dot-matrix impact printers with the parallel connector called the Centronics-37. They were very successful, then went bankrupt when quieter printers took over the market.]
    The 50-pin connector was developed for use in 6-button office telephone systems, which used 25 pairs of wires. But those connectors were used for so long that they were much cheaper than anything like them, so manufacturers could not resist using them.

  • Everyday I load firefox in morning & at the top next to the firefox icon it is written in english. But after a little while it all turns to asian (chinese/japanese) characters. I have to restart my computer to get the english back. What is going on?

    Has firefox been hacked? It is freakin me out & I am going to switch browsers if this cant be corrected.

    This issue can be caused by an extension that isn't working properly.
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    * https://support.mozilla.com/kb/Safe+Mode
    * https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes

  • Compiling Java code with Japanese characters

    I have a Java code with some Japanese characters. My compiler doesn't recognise these characters and gives me error messages.
    Please help me.

    Obviously it's not the copmiler's fault. You need to fix your code.
    Here is a link to the Java Language Specification.
    The link is to section 3.8 - Identifiers.
    It describes the acceptable naming:
    http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#40625
    Perhaps your editor is not saving the text file in an appropriate format.
    What editor are you using?
    Try vim http://www.vim.org
    or SciTE http://www.scintilla.org/SciTE.html

  • Printing Japanese characters in English form

    Hi all,
    i have a requirement to print the japanese characters in the from which is printed in english.
    Actually the customer adress is in japanese but when i am printing it,the japanese characters are not getting printed (text is printed as some square boxes).
    Any ideas to print the japanese text as it is...
    Thanks and Regards,
    Sravanthi Chilal

    Hi,
    Is your text coming from an internal table or it is a standard text that you want to print in adobe form?
    If it is standard text or long text,Creating a Text node by right clicking on the top node  and then
    CREATE -> TEXT.
    In the properties of the TEXT node select Text type Include Text and then provide the Text Name, Text Object, Text ID and Text Language values as shown below.
    Drag the  structure from the interface into the Context. 
    We can pass the Text node properties values dynamically as well.
    If our application makes no use of the Business Address Services but you still want to have country-specific addresses, we must use ABAP coding to achieve this. It is possible to do this in the application program or in the initialization coding of the interface.
    In interface,
    Define Import parameter under Form Interface. 
         IS_CUSTOMER_ID     TYPE     S_CUSTOMER
         IS_COUNTRY          TYPE     LAND1
    TYPES:
      BEGIN OF ty_adr_printform_table_line,
        line_type      TYPE ad_line_tp,
        address_line LIKE adrs-line0,
    END OF ty_adr_printform_table_line.TYPES:
        ty_adr_printform_table TYPE TABLE OF ty_adr_printform_table_line.
    Define Global Work Areas and Internal Tables under Global definition as shown below. 
    IS_ADDRESS           TYPE     ADRS1.
    IT_ADDRESS_LINES     TYPE     TY_ADR_PRINTFORM_TABLE.
    IS_ADDRESS_LINE     TYPE     TY_ADR_PRINTFORM_TABLE_LINE.
    IS_SCUSTOM          TYPE     SCUSTOM.
    SELECT SINGLE *
      FROM  scustom
        INTO  is_scustom
    WHERE id EQ is_customer_id.is_address-title_text     = is_scustom-form.
    is_address-name1     = is_scustom-name.
    is_address-street     = is_scustom-street.
    is_address-po_box     = is_scustom-postbox.
    is_address-post_code1     = is_scustom-postcode.
    is_address-city1     = is_scustom-city.
    is_address-region     = is_scustom-region.
    is_address-country     = is_scustom-country.* Address Format According to Post Office Guidelines
    Note : Refer Function module documentation for more information.CALL FUNCTION 'ADDRESS_INTO_PRINTFORM'
      EXPORTING
          address_1          = is_address
          address_type     = '1'            "normal/company
           sender_country     = is_country
           number_of_lines     = 8
    IMPORTING
      address_printform_table = it_address_lines.
    *******If the customer address in the database table is in english, you cannot print in Japanese.

  • Oracle Report Server Issue with Japanese Characters

    We are trying to setup a Oracle Report Server to print the Japanese characters in the PDF format.
    We have separate Oracle Report servers for printing English, Chinese and Vietnamese characters in PDF formats using Oracle Reports in the production which are running properly with Unix AIX version 5.3. Now we have a requirement to print the Japanese characters. Hence we tried to setup the new server for the same and the configurations are done as same as Chinese/Vietnamese report servers. But we are not able to print the Japanese characters.
    I am providing the details which we followed to configure this new server.
    1.     We have modified the reports.sh to map the proper NLS_LANG (JAPANESE_AMERICA.UTF8) and other Admin folder settings.
    2.     We have configured the new report server via OPMN admin.
    3.     We have copied the arialuni.ttf to Printers folder and we have converted this same .ttf file in AFM format. This AFM file has been copied to $ORACLE_HOME/guicommon/gk/JP_Admin/AFM folder.
    4.     We have modified the uifont.ali (JP_admin folder) file for font subsetting.
    5.     We have put an entry in JP_admin/PPD/datap462.ppd as *Font ArialUnicodeMS: Standard "(Version 1.01)" Standard ROM
    6.     We have modified the Tk2Motif.rgb (JP_admin folder) file for character set mapping (Tk2Motif*fontMapCs: iso8859-1=UTF8) as we have enabled this one for other report servers as well.
    Environment Details:-
    Unix AIX version : 5300-07-05-0831
    Oracle Version : 10.1.0.4.2
    NLS_LANG : JAPANESE_AMERICA.UTF8
    Font Mapping : Font Sub Setting in uifont.ali
    Font Used for Printing : arialuni.ttf (Font Name : Arial Unicode MS)
    The error thrown in the rwEng trace (rwEng-0.trc) file is as below
    [2011/9/7 8:11:4:488] Error 50103 (C Engine): 20:11:04 ERR REP-3000: Internal error starting Oracle Toolkit.
    The error thrown when trying to execute the reports is…
    REP-0177: Error while running in remote server
    Engine rwEng-0 crashed, job Id: 67
    Our investigations and findings…
    1.     We disabled the entry Tk2Motif*fontMapCs: iso8859-1=UTF8 in Tk2Motif.rgb then started the server. We found that no error is thrown in the rwEng trace file and we are able to print the report also in PDF format… (Please see the attached japarial.pdf for your verification) but we are able to see only junk characters. We verified the document settings in the PDF file for ensuring the font sub set. We are able to see the font sub setting is used.
    2.     If we enable the above entry then the rwEng trace throwing the above error (oracle toolkit error) and reports engine is crashed.
    It will be a great help from you if you can assist us to resolve this issue…

    Maybe 7zip or another tool has workarounds for broken file names, you could try that.
    Or you could try to go over the files in the zip archive one-by-one and write it to files out-1, out-2, ..., out-$n without concerning yourself with the file names. You could get file endings back via the mimetype.
    This script might work:
    #include <stdio.h>
    #include <zip.h>
    static const char *template = "./out-%04d.bin";
    int main(int argc, char**argv)
    int err = 0;
    zip_t *arc = zip_open((const char*)argv[1], ZIP_RDONLY, &err);
    if(arc == NULL)
    printf("Failed to open ZIP, error %d\n", err);
    return -1;
    zip_int64_t n = zip_get_num_entries(arc, 0);
    printf("%s: # of packed files: %d\n", argv[1], n);
    for(int i = 0; i < n; i++)
    zip_stat_t stat;
    zip_stat_index(arc, i, ZIP_FL_UNCHANGED, &stat);
    char buf[stat.size];
    char oname[sizeof(template)];
    zip_file_t *f = zip_fopen_index(arc, (zip_int64_t)i, ZIP_FL_UNCHANGED);
    zip_fread(f, (void*)&buf[0], stat.size);
    snprintf(&oname[0], sizeof(template), template, i);
    FILE *of = fopen(oname, "wb");
    fwrite(&buf[0], stat.size, 1, of);
    printf("%s: %s => %lu bytes\n", argv[1], oname, stat.size);
    zip_fclose(f);
    fclose(of);
    zip_close(arc);
    return 0;
    Compile with
    gcc -std=gnu99 -O3 -o unzip unzip.c -lzip
    and run as
    ./unzip $funnyzipfile
    You should get template-named, numbered output files in the current directory.
    Last edited by 2ion (2015-05-21 23:09:29)

  • Display Chinese/Japanese Character

    I upgraded my PC from Windows XP to Windows 7 recently, and after installing the latest iTunes 10.7.0.21, I notice that it cannot display chinese/japanese characters.
    Is there any setting in iTunes or Windows to correct this?

    Have your tried googling your problem?
    I found this article: [http://www.chinesecomputing.com/programming/java.html|http://www.chinesecomputing.com/programming/java.html] That seems promising, but ofcourse I cant tell if it will work on your application without seeing a shred of code.
    Im certain there is others that has had the same problem before, and put up their solutions on the net.

  • Do we need to convert Chinese/Japanese properties to Unicode?

    Dear friends,
    I am new to this Internationalization concept. I have a web application and I am looking forward to implement Internationalization.
    To make my app support muti-language, I am using Locale & Resource bundle to find properties files based on Country and Language. I have different properties files based on countries. This works fine when there are unicode characters and no special characters in the property file.
    For eg. the application doesn't displays Chinese/Japanese characters with System.out.println at all. It displays something weird symbols..
    P.S : I haven't converted Chinese/Japanese properties files to Unicode with native2ascii tool?
    An important question for me is,
    1) Do we need to convert Chinese/Japanese or any non-unicode related properties files with native2ascii tool?
    2) Is there any other way to read such properties files without converting them with native2ascii tool?
    3) We have made fixed UTF-8 format policy for the app. Is there any way to read those properties file with UTF-8 mechanism without need to convert the properties files?
    4) If anyone has quick example code for displaying Chinese/Japanese characters from properties file, then that would be a great help.
    Thanks a million. Any help would be highly appreciated.
    sachin

    System.out.println display depends on the system locale. If you are running on a US English system, Chinese and japanese will not display correctly in the console.
    Your properties file questions:
    1) Do we need to convert Chinese/Japanese or any non-unicode related properties files with native2ascii tool? yes
    2) Is there any other way to read such properties files without converting them with native2ascii tool? - no
    3) We have made fixed UTF-8 format policy for the app. Is there any way to read those properties file with UTF-8 mechanism without need to convert the properties files? no

  • Printing chinese w/ Java Print Service API become garbled characters

    I'm using XP platform and I've a plain text file on my drive.
    Now, what I want to do is, to read the text file in, then print it, that's all.
    However, the printout become messy, just some garbled characters.
    I did try to change quite a different ways to read the file, but the printout is still messy.
    Is there anything wrong? Can somebody give me a help?
    package com.ysf.document.client.ups;
    import java.io.FileReader;
    import java.io.IOException;
    import javax.print.*;
    import javax.print.attribute.*;
    public class Class1
       public static void main(String[] args)
          String filename = "c:\\temp\\abcd.txt";
          DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
          PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
          // locate a print service that can handle it
          PrintService[] pservices = PrintServiceLookup.lookupPrintServices(flavor, aset);
          // create a print job for the chosen service
          int printnbr = 1;
          DocPrintJob pj = pservices[printnbr].createPrintJob();
          try
             int c;
             FileReader f = new FileReader(filename);
             StringBuffer buffer = new StringBuffer();
             c = f.read();
             while (c != -1)
                buffer.append((char) c);
                c = f.read();
             Doc doc = new SimpleDoc(buffer.toString().getBytes("BIG5"), flavor, null);
             pj.print(doc, aset);
          } catch (IOException ie)
             System.err.println(ie);
          } catch (PrintException e)
             System.err.println(e);
    }

    For #1, indeed, it's my overlook, I've corrected it already.
    For #2, it shows, java.lang.ArrayIndexOutOfBoundsException: 1.
    It's mainly because my printer do not support this flavor.
    My printer supports only:
    image/gif
    [B OR java.io.InputStream OR java.net.URL
    image/jpeg
    [B OR java.io.InputStream java.net.URL
    image/png
    [B OR java.io.InputStream OR java.net.URL
    application/x-java-jvm-local-objectref
    java.awt.print.Pageable OR java.awt.print.Printable
    application/octet-stream
    [B OR java.net.URL OR java.io.InputStream
    Up to now, still no solution to it. Anybody help.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • PO Print Output- Doesn't print Chinese characters

    Hi,
    There is customized t-code ZME9F similar to ME9F with an added feature of e-mail to vendor.
    When we process PO through ZME9F, the PO converted to PDF is not printing the chinese characters.when 'Display message' is clicked also it is fine.The print preview of the PO is fine.
    Can you please let me know what is the reason for not printing chinese characters in the conversion of PDF?
    Thanks in Advance,
    Sowmya

    Hi Soumya,
    Please check note 903157.
    Also the notes 812821, 83502, 776507 are helpful.
    Thanks,
    Ashwini.

  • Passing Japanese characters to Java program

    Hi,
    I am using Java POI APIs for creating/modifying excel spreadsheets. The platform is Solaris. The data to be populated contains both English as well as Japanese characters. The input data to Java program comes from a perl program. When I populate the data in excel or even print using System.out.println, it prints ???... for Japanese characters. The data is in SJIS format.
    I tried converting it to UNICODE in java but that doesn't seem to be working.
    I also tried using native2ascii for converting the data to UNICODE before it is fed to Java program using the following command
    native2ascii -encoding SJIS <Input File> <Output File>
    Although it converts the charaters into UNICODE correctly in the form \u8a3c\u523... but when it is input to Java, the program prints the string as such.
    But if this string is hardcoded in the program, the Japanese characters are printed correctly.
    Could anybody please throw some light as to the data should actually be passed to the Java program.
    Thanks

    Sekhar
    Ive realised the solution will probably involve HttpServletRequest.setCharacterEncoding.
    Im now upgrading to Tomcat 4 because 3 didnt support this method. Once I'm through the upgrade, I'll try Japanese the chars again.
    I would guess I need to force my web pages to utf-8 and use HttpServletRequest.setCharacterEncoding(utf-8) in the servlet to get it working ?

Maybe you are looking for

  • Edit Authorization at Entity Level

    Problem: I am trying to Edit Authorization at entity level but my changes are not getting saved. Discription: I have use case that I want to make an entity read only for a role defined in my jazn. To do so, I am opening my entity, and in struture win

  • Non-US purchase - more grief :-(

    There is an evolution in the procedure for non-US cutomers. 1. Launch Ap 2 Trial 2. Click "Buy" - you are taken to a US-centric web page 3. Select "The Netherlands" from the drop down menu - after a moment, the flag turns to the Dutch flag, and the c

  • Excise Account Posting -  In SD Billing (Incomplete)

    Dear Experts, While doing billing in sd the billing document has generated perfectly but in the excise invoice document basic excise line item is coming not ecess and shecess line item generating. Kindly give solutions Billing Document: Customer A/c

  • How can we find out the datasourse is having Beforeimage&afterimage in R/3

    Hi Guru's,      This is Surendra,i have a doubt like' how can we find out the particular datasourse is having before image and after image in R/3 side before we are going to extract the data from R/3 to BW'.Can any body help me in this scenario. than

  • Pb de reinstallation elements 10

    Bonjour, suite à pb, je veux reinstaller photoshop element 10 sous windows 7, j'ai retelechargé depuis la boutique ma commande de 2011.Je lance l'instal et message m'indiquant ( Specified path is empty ).Je ne sais pas quoi faire.De l'aide svp. Dans