?
Solved

How to print Thai characters in PDF from Database

Posted on 2011-05-07
15
Medium Priority
?
1,505 Views
Last Modified: 2012-05-11
Hi
We are generating PDF reports for a client based in bangkok.
The requirement is to generate reoprts in THAI font.
I am using iText to generate the PDF. Thai characters are getting printed correctly when we manually create the file with UTF-8 format.
However the existing PERL code is reading the data from Oracle and writing it to text file, when this is given as input the PDF is getting generated with Junk characters.
- Is there any way where we can set the character set from perl?
0
Comment
Question by:vijayb4u83
  • 7
  • 5
  • 2
  • +1
15 Comments
 
LVL 23

Expert Comment

by:OP_Zaharin
ID: 35711560
- you need to output the text file in UTF-8 format before sending it to PDF
- there are various ways of doing so, see if the following code in perl works:
binmode(STDOUT, ":utf8");

http://stackoverflow.com/questions/627661/how-can-i-output-utf-8-from-perl
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35711594
Why not do the reading from Oracle in Java too?
0
 

Author Comment

by:vijayb4u83
ID: 35711607
I Have tried with these changes already.. its not working still... do we need to set anything while fetching data from DB?
0
Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

 

Author Comment

by:vijayb4u83
ID: 35711612
@CEHJ the solution is already in place to read from perl.. cant help it :(
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35711620
I think you'd also need to check that the Perl is correctly specifying that the driver should use UTF-8
0
 
LVL 23

Expert Comment

by:OP_Zaharin
ID: 35711636
- in the script, set the environment variable locally with the %ENV hash. $ENV{NLS_LANG}. check your database NLS_LANG parameter.  you might also need to set the DBI connector to oracle which encoding to use.
0
 

Author Comment

by:vijayb4u83
ID: 35711684
the NLSLANG is set to .TH8TISASCII. Will try to set the DBI connector
0
 

Author Comment

by:vijayb4u83
ID: 35712025
Hi
I have tried with setting the DB connector however it is still giving ?? for the thai characters.
0
 
LVL 23

Expert Comment

by:OP_Zaharin
ID: 35713857
- can u query the current database character set and paste the result here:

select * from nls_database_parameters;
0
 
LVL 23

Expert Comment

by:OP_Zaharin
ID: 35714015
- if the result of:
NLS_LANGAUGE=THAI
NLS_TERRITORY=THAILAND

- then set the encoding
$ENV{NLS_LANG} = 'THAI_THAILAND.TH8TISASCII';

0
 

Author Comment

by:vijayb4u83
ID: 35717774
Hi Below are the parameters:
Let me try with the encoding you provided.

PARAMETER                      VALUE
------------------------------ ----------------------------------------
NLS_LANGUAGE                   AMERICAN
NLS_TERRITORY                  AMERICA
NLS_CURRENCY                   $
NLS_ISO_CURRENCY               AMERICA
NLS_NUMERIC_CHARACTERS         .,
NLS_CHARACTERSET               TH8TISASCII
NLS_CALENDAR                   GREGORIAN
NLS_DATE_FORMAT                DD-MON-RR
NLS_DATE_LANGUAGE              AMERICAN
NLS_SORT                       BINARY
NLS_TIME_FORMAT                HH.MI.SSXFF AM

PARAMETER                      VALUE
------------------------------ ----------------------------------------
NLS_TIMESTAMP_FORMAT           DD-MON-RR HH.MI.SSXFF AM
NLS_TIME_TZ_FORMAT             HH.MI.SSXFF AM TZR
NLS_TIMESTAMP_TZ_FORMAT        DD-MON-RR HH.MI.SSXFF AM TZR
NLS_DUAL_CURRENCY              $
NLS_COMP                       BINARY
NLS_LENGTH_SEMANTICS           BYTE
NLS_NCHAR_CONV_EXCP            FALSE
NLS_NCHAR_CHARACTERSET         AL16UTF16
NLS_RDBMS_VERSION              11.1.0.7.0
0
 

Accepted Solution

by:
vijayb4u83 earned 0 total points
ID: 35718386
This is now working after using unistr() function for data in sql and in perl file
use open ':utf8'

In Java opening the stream with UTF-8 Format.
0
 
LVL 23

Expert Comment

by:OP_Zaharin
ID: 35718601
- yeah i miss out the open! great is working for you now.
- to print to pdf, u must also use the binmode(STDOUT, ":utf8")
0
 
LVL 1

Expert Comment

by:phutsa
ID: 35745155
so the problem can now prove. I also have a problem with Thai character. good to come here
0
 

Author Closing Comment

by:vijayb4u83
ID: 35814107
Using the unistr() function for data in sql and in perl file
use open ':utf8'
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
This video shows how to recover a database from a user managed backup
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month14 days, 16 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question