JasperReports: Items is pdf are printing on top of each other instead of beside each other - jasper-reports

I'm using JasperReports to generate pdf files for customers. For some reason some items are stacking on top of each other instead of printing beside like they are supposed to.
Here is a design of my report:
Any help is appreciated.

It sounds like you have the "Position Type" set to "Fix Relative to Top". Change it to "Float".
EDIT: I just received a sample report showing the same behavior. It looks like a bug to me. In that case I got the desired output by appending a space. "JG" would break into 2 lines. But "JG " would be rendered on a single line. I cannot explain this. It's clearly a bug. But if you are hitting the same behavior, then appending a space might solve it for you as well.

Related

jasperreports studio - hard to get the column header to line up with the detail

I have headers/details in the jasper reports studio. everything about this works wonderful minus one annoying thing I have to constantly line up the column headers with the details to make the alignments act correctly... even though i match the alignment exactly in the designer.
This is probably because I have a different font style on Header versus detail... or something? I'm not sure.
I can workaround the issue by manually tweaking X-coords, export the report, make sure they line up, until it looks nice... resulting in a designer like this:
Notice how I moved the values in the Detail 1 band to the left so that the report with actual values lines up the columns correctly.
I must just be doing something wrong right? Why do I have to do this manual tweak to get things to look ok?
I had the same issue when using Jaspersoft Studio.
I'd recommend you to use iReport instead, it's much more convenient for JRXML development and does not have this annoying issue in fields alignment.
It seems that the cells in "Detail 1" are set to display centralized text while the ones in the "Column Header" are left aligned. Try left aligning the text in the Detail 1's cells and see if things work out.

jasper text field getting truncated

I'm having a font issue with my jasper report where one of my more wordy text fields (the last one in a detail band) is getting cut off in the PDF and PDF Preview but not in the Internal Preview.
e.g.
Internal Preview:
Here is a fake description. It fits
perfectly, fitting just in the lines.
PDF Preview
Here is a fake description. It
fits perfectly, fitting just in the
Jasper is (seemingly) using some algorithm to figure out how tall the field should be, my text is barely fitting, then when the PDF is generated the text wraps and disappears on the next line.
I'm not using custom fonts (just the default/implicit "SansSerif"), and not using any custom styles beyond bold/italic. This behavior is demonstrable in both iReport's PDF Preview and my code's generated PDF on Windows and MacOS (Linux likely still has the issue, but my example text didn't exhibit the behavior on Ubuntu).
I've played with Stretch Type, Position Type, and Stretch with Overflow, as well as moved this text field to its own band but none fixes this bug (and several of them cause others).
I've had luck changing the font to the other built-in fonts, but this just tells me my example doesn't work for that particular font, not that I've fixed the bug.
Any tips would be greatly appreciated.
Update 1
I tried upgrading from Jasper Reports 5.2.0 to 6.2.0 and Jasper Fonts 4.0.0 to 6.0.0... no change.
Update 2
Tried editing my src/main/resources/jasperreports_extension.properties and adding
net.sf.jasperreports.export.pdf.force.linebreak.policy=true
... no change.
(Notably though in my use-case I can't use isStretchWithOverflow="true", so this may be why it didn't work.)
Update 3
I tried embedding the font by editing src/main/resources/jasperreports_extension.xml and adding:
net.sf.jasperreports.extension.registry.factory.fonts=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
net.sf.jasperreports.extension.simple.font.families.arialFontFamily=fonts/customFontFamilies.xml
customFontFamilies.xml:
<?xml version="1.0" encoding="UTF-8"?>
<fontFamilies>
<fontFamily name="ArialEM">
<normal><![CDATA[fonts/Arial/Arial.ttf]]></normal>
<bold><![CDATA[fonts/Arial/Arial Bold.ttf]]></bold>
<italic><![CDATA[fonts/Arial/Arial Italic.ttf]]></italic>
<boldItalic><![CDATA[fonts/Arial/Arial Bold Italic.ttf]]>/boldItalic>
<pdfEncoding><![CDATA[Cp1252]]></pdfEncoding>
<pdfEmbedded><![CDATA[true]]></pdfEmbedded>
</fontFamily>
</fontFamilies>
... no dice. (Though this did help with an issue where Firefox's PDF renderer wouldn't render bold fonts.)
Update 4
I noticed that in all the test-cases I was able to create that the first line was blank, so I changed the particular cell to be vertical-align top, which worked, but of course made that one cell misalign when there wasn't much text in it.
Scrapped that as a solution, but may work for someone.
Update 5
At this point hopefully it's clear I've tried the "real" solutions and watched them all die a horrible death. Thus, we enter the realm of the hack solution. First I tried #wmmci's solution, but his answer changes the height of my box (due to it being dynamically calculated by Dynamic Jasper). I noticed that all of the examples I could create involved intra-word periods in the string, e.g. "foo...bar". That might not be your case, but it was for me. So I injected a "hair space" ( ) after intra-word spaces.
This is obviously not a real solution, just a temporary work-around until I'm able to find more examples of the bug.
Update 6
I checked and I don't have #KarolisŠarapnickis's issue with the printOrder. Ah well. I shall soldier on. ;-)
I had same issue and I tried all possible configurations - didn't work. Finally as a workaround I appended a new line character to the field and it worked.
Something like this: $F{description} + "\n"
Had the same issues with text being truncated and nothing seemed to work.
luckily I found out that my root xml element had the following attribute:
printOrder="Horizontal"
Removing it solved my issues.
Well, i'm not sure if you're struggeling with the exact same problem i was.
But my solution was setting the property "net.sf.jasperreports.print.keep.full.text" of the field to "true".
In my case, I had really long text in a single text field. Adding a line break would solve the issue for some cells, but not for the really long ones that spanned pages. To finally solve it, I had to set the text field to stretch to RELATIVE_TO_BAND_HEIGHT. Previously, it was set to RELATIVE_TO_TALLEST_OBJECT. My guess is that, RELATIVE_TO_TALLEST_OBJECT was being calculated incorrectly (lower than needed).
This did the trick:
textField.setStretchType( StretchTypeEnum.RELATIVE_TO_BAND_HEIGHT );
Seems like the only working solution is to put some text formating signs as #wmmcii said. Then another text renderer is used (discused here). However the new line \n is not ideal, because there is unwanted influence to the output doc. Better solution seems to put tab sign \t to the end of the line. To avoid additional problems when using Horizontal Alignment = Justified, put also a space prior to tab sign. For example:
$F{my_text} + " \t"

Jasper reports: Overlapped fields not shown in excel output

Take the following example:
I have one very wide column (lets say 150pt), positioned on x=0
I have 2 columns of 25pt, positioned on x=100 and x=125. Thus, these are overlapping the first.
Depending on certain conditions (parameters to the report), I do or do not print the 2 overlapping columns. I do this by using the "print when expression ...".
This works like a charm when I use the PDF as output, but when I generate the report in excel, I do not get the big field, it is just missing. As long as I do not print the 2 overlapping fields, everything remains OK.
Any ideas on how to solve this one?
Thanks
Sounds like the answer is no ... hopefully there is a better answer
http://community.jaspersoft.com/questions/503288/missing-columns-excel
... the columns are overlapping. And the so-called "grid
exporters" like the HTML, XLS and CSV exporters do not support
overlappging elements. The elements that are behind do not print.
I hope this helps. Teodor

How to remove blank spaces when report element is not printed?

PDF generated using jasper, is having blank spaced when report element is not printed(Used printWhenExpression).
I tried to set removeBlankSpace property but This also didn’t work resolve issue at all places.
Please help me if there is any solution. I will try.

FOP: unwanted linebreaks in nested <fo:block> elements

I have a Problem conecerning FOP. I am using CKEditor to create an XSL-Fo String and transform that into a PDF using FOP. Everything works fine, but when using nested blocks, I experience linebreaks in the PDF that should not exist.
XSF-FO:
...<fo:block>ONE<fo:block font-weight="bold">TWO</fo:block><fo:block font-style="italic">THREE</fo:block><fo:block text-decoration="underline">vier</fo:block><fo:block class="linebreak"/></fo:block>...
(The XSL-FO is not complete, the root element and other things are missing. But as other things things like tables and lists are working just fine, there should not be any errors in the document structure.)
The resuling PDF looks somewhat like this:
ONE
TWO
THREE
I just have no idea why?
Thx in advance for an help :)
fo:block always takes a whole line. If you need few items on line you can use fo:inline (to change font, colour etc.) or tables (if you also need to control width of items)