jasper text field getting truncated - jasper-reports

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"

Related

t's changed to "ti" when exporting to PDF

My Crystal report generates this text:
This is to certify that {FullName} has completed the course
where the formula {Fullname} is: Mr. + Name
I want to change {FullName} to remove the title "Mr". I used Find in Formulas on {FullName} and changed the Display String from Mr. + {?FullName} to {?FullName}. But somehow this replaced every lowercase "t" with "ti". So now the static string is changed to:
This is tio certify tihati .... has successfully completied tihe course
How can I correct this? A key note is that this only happens when exporting to PDF. In the Main Report Preview, the report displays correctly.
What you're describing is a really weird bug involving the Calibri font. Certain glyphs aren't handled correctly when exporting to PDF. The solutions I've found are as follows:
A) Avoid using Calibri fonts in Crystal Reports. You might try a more
common True Type font, such as Arial. Again, be sure that font is
installed on every... workstation.
or
B) Downgrade Crystal Reports to use a legacy Microsoft Uniscribe
component (USP10.dll). Here’s the procedure that we’ve used at
Alterity with good results.
Here are advanced instructions for Solution B, but I'd just recommend changing fonts. I'm sure you can find one very close to Calibri without this issue.

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.

Is there an option to control output page orientation (using knitr->pander->pandoc->docx)

I am playing with Tal's intro to producing word tables with as little overhead as possible in real world situations. (Please see for reproducible examples there - Thanks, Tal!) In real application, tables are to wide to print them on a portrait-oriented page, but you might not want to split them.
Sorry if I have overlooked this in the pandoc or pander documentation, but how do I control page orientation (portrait/landscape) when writing from R to a Word .docx file?
I maybe should add tat I started using knitr+markdown, and I am not yet familiar with LaTex syntax. But I'm trying to pick up as much as possible while getting my stuff done.
I am pretty sure the docx writer has no section breaks implemented, also as far as I understand --reference-docx allows for customizing styles and not the page layout (but I might also be wrong here), this is from pandocs guide on --reference-docx:
--reference-docx=FILE
Use the specified file as a style reference in producing a docx file.
For best results, the reference docx should be a modified version of a
docx file produced using pandoc. The contents of the reference docx
are ignored, but its stylesheets are used in the new docx. If no
reference docx is specified on the command line, pandoc will look for
a file reference.docx in the user data directory (see --data-dir). If
this is not found either, sensible defaults will be used. The
following styles are used by pandoc: [paragraph] Normal, Title,
Authors, Date, Heading 1, Heading 2, Heading 3, Heading 4, Heading 5,
Block Quote, Definition Term, Definition, Body Text, Table Caption,
Image Caption; [character] Default Paragraph Font, Body Text Char,
Verbatim Char, Footnote Ref, Link.
Which are styles that are saved in the /word/styles.xml component of the docx document.
The page layout on the other hand is saved in the /word/document.xml component in the <w:sectPr> tag, but pandoc's docx writer ignores this part as far as I can tell.
The docx writer builds by default a continuous document, with elements such as headers, paragraphs, simple tables and so on ... much like a html output.
Option #1 (doesn't solve the page orientation problem):
The only page layout option that you can define through styles is the pageBreakBefore which will add a page break before a certain style
Option #2 (seems elegant but hasn't been tested):
Recently the custom writer has been added that allows for a custom lua script, where you should be able to define how certain Pandoc blocks will be written into the output file ... meaning you could potentially define section breaks and page layout for a specific block inserting the sectPr tag into the document. I haven't tried this out but it would be worth investigating. On pandoc github you can check out a sample lua script file for custom html output.
However, this means, you have to have lua installed, learn the language, and it is up to you if you think its worth the time investment.
Optin #3 (a couple of clicks in Word might just do):
As you will probably spend quite some time setting up how to insert sections and what would be the right size, margins, and figuring how to fit the table to such a layout ... I recommend that you use pandoc to put write your document.docx, that you open in Word, and do the layout by hand:
select the table you want on the landscape page
go to Layout > Margins
> select Apply to: Selected text
> choose Page Setup > select Landscape
Now a new section with a landscape orientation should surround your table.
What you would anyway also probably want to do is styling the table and table caption a little (font-size,...), to achieve the best result (all text styling can be already applied with pandoc where --reference-docx comes handy).
Option #4 (in situation when you can just use pdf instead of docx):
As far as I could figure out is that with pandoc does a good job with tables in md -> docx (alignment, style, ... ), in tex -> docx it had some trouble sometimes. However if your option allows for a pdf output latex will be your greatest friend. For example your problem is solved as easily as just using
\usepackage{pdflscape}
and adding this around your table
\begin{landscape}
...
\end{landscape}
This are the options that I could think of so far.
I would always recommend using the pdf format for reports, as you can style it to your liking with latex and the layout will stay the way you want it to be.
However, I also know that for various reasons word documents are still the main way of reviewing manuscripts in many fields ... so i would most likely just go with my suggested option 3, mostly cause it is a lazy and quick solution and because I usually don't have many documents with tons of giant tables with awkward placement and styling.
Good luck ;-)
Based on Taleb's answer here and some officer package functions, I created a little gist that one can use like this:
---
title: "Example"
author: "Dan Chaltiel"
output:
word_document:
pandoc_args:
'--lua-filter=page-break.lua'
---
I'm in portrait
\endLandscape
I'm in landscape
\endPortrait
I'm in portrait again
With page-breaks.lua being the file hosted here: https://gist.github.com/DanChaltiel/e7505e62341093cfdc489265963b6c8f
This is far from perfect (for instance it won't work without the last portrait section), but it is quite useful sometimes.

Remove Bold entirely from MS Word Document 2007/2010 using Open XML SDK

I'm playing around with Open XML SDK and trying as an excercise to remove any bold entries in a document and also changing any family fonts to "Courier New" Size 10 and while it works for 90% of the document, the remaining 10% are driving me nuts!!
Is there a way ensure that all "Bold" entries are fully made "non-bold" and replaced with the given font and size? For some reason, it does not seem to apply to some text in the document, the table of content and fonts formatted with headings...
Any ideas? Also, will I encounter other issues as I deal with other types i.e. Tables or other? Do each type need to be deal with individually?
If you can provide me with a sample code in C# on how to deal with this, it would be great! I'd like to be able handle all scenarios ... Most of the samples I'm finding are showing how to set things, but not how to unset them if already set.
Thanks.
Thierry

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

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.