I have some troubles with JasperReports. I generated a formular with iReport including two subreports which generates a grid of values (1 or 2 Characters long).
The compiled PDF from iReport it works fine and looks good, but if i use the same *.jrxml and *.jasper files for my web app the generated PDF has some minor differences. One big problem is, that some cells of the grid now are 2 lines high. Values like "NB" only use one line but "GS" for example uses 2 lines.
For me it is not possible to find the error. Workarounds with smaller font size or wider cells didn't help.
Make sure the font you are using in the template is available on the JVM generating the report. If the font doesn't exist then a different font will be used. If changing the font isn't an option then you can create a font extension package. Creating a font extension is documented here: JasperReports Font Reference
Sound like you could have a different version of iReports in your web application. Making the cells sufficiently wide enough should at least allow the text to span just one line.
Create a Java Desktop test that generates a PDF based on the .jrxml and make sure it has the same results. If it does then there is something with the way iReports is working, if it doesn't then you know it is something with how you are viewing or creating the PDF in the web app.
Related
JasperReports library seems to be miscalculating how many new lines the text field need to fit all its contents. In JasperReports Studio (in preview) everything looks fine, but not when exporting to PDF from my application.
I've read PDF FAQ from JasperReports and I tried setting PROPERTY_FORCE_LINEBREAK_POLICY in the report to true, but this didn't make any difference. I also experimented with various fonts, but then in runtime Java complained about missing font in AWT, so I guess my default font (SansSerif) is just fine.
When I print "english only" version of the report, then everything looks okay, because all texts are about a half in length, but when using longer texts (like in example below) then this line miscalculation happens.
Here is how it looks right now and I marked unwanted extra lines with red:
Since I've tried with both hints from JasperReport's PDF FAQ, what else can I do?
I found the solution:
Switch all fonts to Dejavu (I used to use default fonts)
Have a jasperreports-fonts extension included in the project.
The new font is a tiny bit wider, but that's okay. Other than that it looks very alike.
I'm trying to generate PDF document in Java using iText. link
But I also want to give users an opportunity to choose which font to use for the document. There are many fonts, installed in the system, I can list them using
GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
but when I try to pass font names to BaseFont constructor directly
BaseFont.createFont(s, BaseFont.IDENTITY_H, true);
I get an exception like
com.lowagie.text.DocumentException: Font 'Abyssinica SIL' with 'Identity-H' is not recognized.
Another option is to pass to the BaseFont the path to the font file (either stored inside jar or somewhere on the system), but in the first case I have to deploy all the fonts with my application, and in the second case I have to think of a way of getting system font files locations. As far as I know, Java puts a layer of abstraction over fonts - public API doesn't know anything of paths, and usage of private API (something like FontManager) is discouraged.
Yet another option is to use constants, declared in BaseFont , but that gives only 4 fonts (Courier, Helvetica, Symbol and Times Roman).
Is there a way to use system fonts in PDFs, generated with iText without deploying them with application and using workarounds like FontManager?
I would like to create a report that has the following layout:
It has three parts as you can see. The third part is a subreport done as a list, that is the easy part! My question is this: is there a better way of doing the first two parts than drawing boxes and lines in element groups and doing crazy calculations with positioning them? (I am talking about the .jrxml)
Try using iReport. It is a gui application for designing jasper reports.
You can drag and drop text fields and other report elements, so you don't have to worry about positioning.
I have had several problems using the .jrxml gerenated by iReport, but finally I have found an artikle that explains how to use iReport. It also explains how to fill the report.
I have had problems since I was using a manually written .jrxml, which had to be compiled and filled. Now based on the code in the artikel I am not using .jrxml anymore, but the .jasper file compiled by the iReport and everything works like a charm.
I'm running across a problem trying to print a crystal report in java where all of the text is being replaced with the little box characters. The report blob is stored in an Oracle database, and I can preview it using adobe reader and see that it is properly formed with actual text. This blob is passed to a java applet that uses the PDFRenderer to print it.
My theory is that the problem lies in the fact that the crystal reports that we generate use version 1.2 of PDF. There are also a number of jasper reports that are generated as version 1.4 and these print correctly - it's only the 1.2 pdfs that have this problem.
Does PDFRenderer not support printing this version or is there some additional steps I need to take to successfully print those?
Any help is greatly appreciated.
It's very unlikely that you encounter an issue that's due to PDF version.
Especially with text content the PDF spec get's very complex and probability is high that crystal reports creates content that either
relies on some strange encoding
uses CID (multibyte) font techniques
and pdf renderer has a blind spot there.
You may try to play around with settings on the report side regarding the
encoding
font (Type1 / TrueType9)
font embedding
and maybe you find an option better suited.
Does PDFRenderer display the PDFs if you use it as a viewer? PDFRenderer does not have support for later PDF versions (ie compressed objects) but 1.2 is fairly straight-forward.
I have to internationalize an application, and therefore have to let a user chose a font for a PDF that I will create at runtime. I want to be able to display a list of font choices from the user's system using
GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
This works fine for getting fonts, but then it seems that I have to jump through some hoops to get that font to play nice with FOP, as outlined here. I can follow all the instructions that they've outlined, except I'm not sure how to get the location of fonts in order to run TTFReader.
Does anyone know how to list the path of each font that java gathers with the getAllFonts() command?
Is it a good idea to embed fonts in PDFs? For instance the Arial Unicode MS TFF file is ~ 30 MB.
Is this the only way to create internationalized pdfs with FOP and XSL?
There have been major improvements in font configuration with the last release (FOP 0.95), so please just consult the document there for a much easier approach:
http://xmlgraphics.apache.org/fop/0.95/fonts.html#basics
The XML font metrics files are no longer necessary.
To your questions:
That's impossible. Java won't give you that information. That's partly why FOP has its own font subsystem.
Yes, it's actually recommended. Please note that FOP supports font subsetting so only the glyphs needed are embedded in the PDF.
Not sure what you mean. With the above information and an upgrade to the latest release should make this simple enough.