Jump to content
We've recently updated our Privacy Statement, available here ×

export jasperPrint as JPG


zol777

Recommended Posts

My program is going export a JPG image using the following code. It is successfully export a page as JPG but all chinese character is displayed as boxes.
 

Code:

It is interesting that If i export the JasperREport as PDF/HTML, the chinese font is displayed correctly.

I have looked into some documents. It seem AWT component display chinese character as box if a chinese font is missing JRE/lib. Does it related to my problem?

Can any one give me a suggestion for my problem!?

My environment:

Jasper Report version : 1.3.3
JDK version : 1.4
Platform : Unix
Librariies : I have put IText , IText-Asian and iTextAsianCmaps in my classpath according to jasper report's FAQ

Thank you very much!
Post edited by: zol777, at: 2008/06/16 13:16

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

The Java/AWT font you are using for the text element (via the fontName) attribute doesn't have Chinese glyphs. Make sure that the font given by the fontName attribute is available in the JVM and that it supports Chinese characters.

 

Regards,

Lucian

Link to comment
Share on other sites

Thank you for your kindly reply.

 

 

but how can I "Make sure that the font given by the fontName attribute is available in the JVM and that it supports Chinese characters" ?

 

 

Method 1. Install the font involved in JRXML on unix platform (Does restart is required after installation?)

 

 

OR

 

 

Method 2. update the font.properties of my JRE using as

http://www.chinesecomputing.com/programming/java.html does

 

 

 

OR

 

 

Method 3. add the font to my classpath such as

java -cp classpath chinesefont.ttf myreport

 

 

Does any one of above method feasible can achieve "Make sure that the font given by the fontName attribute is available in the JVM and that it supports Chinese characters" ?

 

 

If No. Pls help to suggest?

 

 

thx.

Link to comment
Share on other sites

I think the best way to find out how to install fonts in Java is to consult the JDK documentation. The font installation mechanism differs from one JDK implementation to another, there is no generic procedure.

 

Usually, JDK implementations automatically use all the fonts installed in the operating system, so the first approach you could take could be to install the required fonts in the OS. I don't know whether you need to restart the system, refer to the OS documentation to find out.

 

If you use a 1.6 JDK, you can also register fonts programmatically via GraphicsEnvironment.registerFont.

 

Regards,

Lucian

Link to comment
Share on other sites

Fonts involved of my JRXML are ONLY from in IText-Asian and iTextAsianCmaps like

 

 

<reportFont name="Arial_Normal" isDefault="false" fontName="Arial" size="11" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="MSung-Light" pdfEncoding="UniCNS-UCS2-H" isPdfEmbedded="true"/>

 

 

But when i extract IText-Asian and iTextAsianCmaps, No TTF(font file like file) is included. It seem have some mapping file ONLY.

 

 

So did the font in my report are using asian font pack of adobe pdf but not from IText-Asian and iTextAsianCmaps?

 

 

In order to install the required fonts in the OS, should i go to install the asian font pack that using in PDF?

 

 

If the above assumption is corrected, so if I can read the chinese PDF in my unix after installation those required font that mean my problem is resolved?

 

 

Moreover, I have read FAQ that API provide that i can convert the file to SVG. So can i convert jasperprint to SVG and then to JPG? In the conversion of jasperprint to SVG, Does it require involve any class from package of java.awt.*?

 

 

thx

Post edited by: zol777, at: 2008/06/18 02:08

Link to comment
Share on other sites

To andhdo:

 

your method will not work since JasperPrintManager.printPageToImage is involved

 

In JasperPrintManager.printPageToImage, call java.awt to draw JasperPrint Object. It is unable to print chinese character in propery manner if java.awt don't support that font

 

Anyway thx to ur help

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...