mikij Posted November 21, 2008 Share Posted November 21, 2008 Hi,I have problem with setting Locale to report. In my iReport locale is set to "Serbian (Serbia and Montenegro)", "sr" and my report is running good. But, when I run my report (in PDF) programatically from Struts 2 application, I try to set Locale like this:Locale srLocale = new Locale("sr", "CS");parameters.put(JRParameter.REPORT_LOCALE, srLocale);jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn); But it doesn't recognize this locale and I don't see those letters in generated PDF. Default encoding is UTF-8, both in iReport and Web app. How can I fix this ? Link to comment Share on other sites More sharing options...
C-Box Posted December 9, 2008 Share Posted December 9, 2008 For PDF export you should set the correct encoding at TextElement level. There is a special PDFEncoding Attribute for each TextElement. hthC-Box Link to comment Share on other sites More sharing options...
mikij Posted December 10, 2008 Author Share Posted December 10, 2008 Yes, I have put "CP1251 (Cyrillic)" for PDF encoding, and it is good when I run my report from iReport, but when I run it from my Web application (Struts2-based), I get all such text, i.e. characters one on another, like there is no spacing between charaters ? --Thx, Miki Link to comment Share on other sites More sharing options...
mikij Posted December 10, 2008 Author Share Posted December 10, 2008 Actually, iReport show me good report in JasperViewer, but when I save it to PDF I get the same result as from my application. All cyrillic text (characters) is shirnk, so one character is drawn on another, etc. How can I solve this problem ? --Thx. Link to comment Share on other sites More sharing options...
mikij Posted December 10, 2008 Author Share Posted December 10, 2008 If I save it to xls then it is good, but I need to have pdf :(. When I set cp1251 my text in generated pdf is overlapped and if I set "In dentity-H" I don't see any text in my pdf. This problem is described here: http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=34919, but I don't see how can I solve this ? Maybe the problem is with used iText 1.3.1 and its support for cyrillic ? I'm using Helvetica for PDF and JasperReports 3.0 (with iReport 3.0). It seems that Helvetica doesn't have cyrillic, but I cannot choose e.g. from PDF Encoding list ? Please help, I NEED this and I'm totaly stuck :-(!!Post Edited by Miki Ziki at 12/10/08 22:01 Link to comment Share on other sites More sharing options...
lucianc Posted December 11, 2008 Share Posted December 11, 2008 You need to use a PDF font that includes Serbian Cyrillic glyphs. Take a look at the demo/samples/unicode sample whipped with JasperReports for an example of a report that displays Cyrillic text.Regards,Lucian Link to comment Share on other sites More sharing options...
mikij Posted December 11, 2008 Author Share Posted December 11, 2008 Dear Lucian, O.K. Thank you very much. I have found this example, and I opened it in iReport and passed one cyrillic string for its paramter, e.g. "ТЕСТ", and reports is shown good, but when I save it to pdf I just get an empty page!! I noticed this if I switch pdfEncoding of any field to Identity-H I just get an empty pdf document!! I noticed this earlier, for example I create new empty report in iReport, create just one (even non-cyrillic) text field on it with Identity-H for encoding, show this report and when I save it to pdf it is empty document! What is the problem ?! Thank you! --Miki Post Edited by Miki Ziki at 12/11/08 12:11 Link to comment Share on other sites More sharing options...
lucianc Posted December 11, 2008 Share Posted December 11, 2008 Try to run the sample via Ant (do ant javac compile fill pdf). The sample has not been designed for iReport, and you might have to perform some additional tasks to run it in iReport (e.g. you'll have to make sure that the PDF fonts used by the report are present on the classpath).If you encounter problems when running a report in iReport, make sure you check the output console for any exception stacktrace.Regards,Lucian Link to comment Share on other sites More sharing options...
mikij Posted December 11, 2008 Author Share Posted December 11, 2008 Dear Lucian, O.K. I set everything, I registered fonts with FontFactory.register in my application and now works fine! --Miki Post Edited by Miki Ziki at 12/11/08 17:07 Link to comment Share on other sites More sharing options...
mikij Posted December 11, 2008 Author Share Posted December 11, 2008 Actuall I have a problem. This is the worst thing, it worked first but now it doesn't work :-(! I set font like this in my Web app: FontFactory.register("c:\windows\fonts\ARIAL.TTF");FontFactory.register("c:\windows\fonts\ARIALBD.TTF"); before calling fillReport(...), ffter this I try to look which fonts I've succesfully registered: Code: System.out.println("These fonts were registered at the FontFactory:rn"«»);for (Iterator i = FontFactory.getRegisteredFonts().iterator(); i.hasNext(); ) { System.out.println((String) i.next()); System.out.println("rn"«»);}[/code] And It shows correctly the fonts I've installed, and it worked fine, but now I get an exception and I don't know why because I didn't change a thing, and these fonts exist on this location. Both fonts are registered because I don't get any exception, like IOException "file not found" or similar. What am I doing wrong ?! Please help! Code: Post Edited by Miki Ziki at 12/11/08 22:39 Link to comment Share on other sites More sharing options...
lucianc Posted December 12, 2008 Share Posted December 12, 2008 If you want to use com.lowagie.text.FontFactory to register PDF fonts, you'll have to use the actual font name (i.e. "Arial" or "Arial Bold") as pdfFontName.HTH,Lucian Link to comment Share on other sites More sharing options...
mikij Posted December 12, 2008 Author Share Posted December 12, 2008 Dear Lucian, O.K. But I'm not sure what you propose now ? I have put ARIAL.TTF and ARIALBD.TTF for pdfFont in my reports, as in your example. Should I change this or should I remove FontFactory registering or something else, because when I remove FontFactory.register(...) I also get the same exception ("Could not load the following font: ARIALBD.TTF, etc.) ? Update: I put Arial and Arial Bold in my report and it works now in my web app when I register fonts with FontFactory.register. But in this way, when my report is shown in JasperViewer and I save it to pdf I just get an empty page. So, I cannot have both ? I'm just curious, but certainly I need more the first variant.--Thank you in advance, Miki Post Edited by Miki Ziki at 12/12/08 12:59 Link to comment Share on other sites More sharing options...
lucianc Posted December 12, 2008 Share Posted December 12, 2008 I didn't suggest you to use FontFactory, but if you want to do so you'll have to do it in all applications in which you want to run the report (I don't know where you are using JasperViewer from, but I assume it's not from the web application). Otherwise, pdfFontName="Arial" would not work. Note that PDF fonts can also be registered via net.sf.jasperreports.export.pdf.font.* properties.So you need to decide what best suits your application's architecture. If you can use FontFactory (directly or via the JR properties), fine. Otherwise, place the *.ttf files on the application classpath and use pdfFontName="arial.ttf".Regards,Lucian Link to comment Share on other sites More sharing options...
bulut Posted January 10, 2009 Share Posted January 10, 2009 Hi, You don't need to use FontFactory.register. Just move ttf files to your web application's classpath. Link to comment Share on other sites More sharing options...
bulut Posted January 10, 2009 Share Posted January 10, 2009 Post Edited by bulut bulut at 01/10/09 18:23 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