ziden Posted September 24, 2010 Share Posted September 24, 2010 Hello there. Ive found some topics at this and other forums about this, but im a Jasper begginer and couldnt doit. Ive got a database witch will have a string containing HTML simple tags such as BOLD or ITALIC witch is working perfectly. I also have some Unicodes such as \u2663 , witch in this fact is the "clubs" from card set. The fact is, in Jasper Preview it works perfectly, but when it comes to PDF it doesnt work. Im using jasper 3.7.4 and im not initializing the jasper via Java till now, still only workin at Ireport. Is there any simple solution to this ? Thanx alot for any help. []´s Gabriel Ziden Link to comment Share on other sites More sharing options...
ziden Posted September 24, 2010 Author Share Posted September 24, 2010 Sorry for the double posting.Ive got a 'half way' solution to this. Ive added the following to my code: HashMap fontes = new HashMap(); HashMap fontMap = new HashMap(); FontKey key = new FontKey("Arial", false, false); //(String fontName, Boolean bold, Boolean italic) PdfFont font = new PdfFont("C:/windows/Fonts/ARIAL.TTF", com.lowagie.text.pdf.BaseFont.IDENTITY_H ,true); //(String pdfFontName, String pdfEncoding, Boolean isPdfEmbedded) fontMap.put(key,font); exporter.setParameter(JRPdfExporterParameter.CHARACTER_ENCODING, "UTF-8"); exporter.setParameter(JRPdfExporterParameter.FONT_MAP, fontMap); This way, when i run the PDF throw Java and not thro Ireport, i can see the /u unicode characters. However, i had a simple HTML formatting in strings such as <b> and <br> , witch, dont run anymore if i use those lines. Another problem is, im using Arial witch is a Windows Font. I wish to know if is there any font option that includes Linux OS, witch is our server and DB. Thanx for any help. []´s Gabriel Link to comment Share on other sites More sharing options...
kingananth007 Posted September 27, 2010 Share Posted September 27, 2010 Problem 2 - Use ARIALUNI.TTF which is a opensource. Keep that font in your class path..that will do. Problem 1 is nt clear to me. Link to comment Share on other sites More sharing options...
ziden Posted September 27, 2010 Author Share Posted September 27, 2010 Ive added ARial Unicode on my classpath, embed on PDF, made a JAR out of it and implemented that jar on classpath... still, the PDF aint showing the unicode character =(Post Edited by ziden at 09/27/2010 15:18 Link to comment Share on other sites More sharing options...
Teodor Danciu Posted September 28, 2010 Share Posted September 28, 2010 Hi, First of all, you need a TTF file that supports that special character you have.It seems Arial has that character. Then you need to be aware that for bold and italic to work in PDF, you need special TTF files that are bold and italic. Check your Windows fonts folder again and see that there are several Arial files there, not one.With your code, you only mapped the normal one, not the bold, italic and the bold/italic TTFs. Finally, you need to be aware the those exporter parameters you are setting from code are now deprecated. JR/iR nowadays have support for what we call font extensions.These are specially configured JAR files containing fonts that you simply put in your classpath and thus make the fonts available with your application/reports.iReport has a wizard for creating and installing font extension JARs. If you want to learn more about fonts in JR/iR, check the /demo/samples/fonts sample and the /demo/samples/unicode sample shipped with the JR project. Also check the /demo/fonts folder of the JR project to see how a prepackaged font extension JAR containing the DejaVu open source fonts is made of. I hope this helps.Teodor Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now