[#11336] - The report does not export the correct data to Word table

Bug report
Feedback Requested
Project: Severity:
Component: Reproducibility:
Assigned to:


I have a problem when I am trying to export a report to Word, the reports show the correct data on web service, but when I export data to Word (docx), I have text cutted in many cells. In Jaspersoft Studio I have configured the band split type to 'Prevent' and all band fields with stretch type 'Relative To Tallest Object'. I have tried to configure all band fields with padding but it does not work, What can I do? I add some pictures to show you the case.



Image icon word.png96.37 KB
dmarin's picture
Joined: May 18 2017 - 4:21am
Last seen: 9 months 4 weeks ago


  • Resolution:Open» Suspended
  • Resolution:Suspended» Open
  • Status:Acknowledged» Confirmed


We stuck with the same problem, investigated it, and found the “incorrect pixels to points conversion” issue.

In JasperReports, all measures are stored in pixels. Pixels are device-dependent units. DOCX cell paddings are stored in twips (1/1440 inch). Twips are device-independent units.
When DOCX file is generated, JasperReports converts 1 px of each Border Paddings measure to 1 pt (20 twips) of Word table cell paddings measure. That causes vertical overflows of text as shown in the attached picture.

Assuming the 600 x 800 screen resolution and
1 horizontal px = 1 pt = 20 twips,
1 vertical px = 600/800 * 1 pt = ¾ pt = 15 twips.

For example, if we set Border Paddings for left, right, top and bottom to 4 px, these measures should be converted to Word table cell paddings so: left and right – 4 pt (80 twips); top and left – 3 pt (60 twips). After fixing that, the same text is displayed in Word table cells without cropping.
In Visual Basic, conversion between twips and screen pixels is achieved using functions such as TwipsPerPixelX and TwipsPerPixelY.

We fixed this problem for our reports by overriding DocxBorderInfo class:

* Overridden Jasper DocxBorderInfo class for fixing pixels to points conversion.
public class OurDocxBorderInfo extends DocxBorderInfo {

public OurDocxBorderInfo(JRLineBox box) {
borderPadding[TOP_BORDER] = String.valueOf(verticalPixelsToTwips(box.getTopPadding().intValue()));
borderPadding[BOTTOM_BORDER] = String.valueOf(verticalPixelsToTwips(box.getBottomPadding().intValue()));

public OurDocxBorderInfo(JRPen pen) {

private static int verticalPixelsToTwips(float pixels) {
return (int) (pixels * 15); // 1 vertical px = 3/4 pt = 20 twips/pt * 3/4 pt = 15 twips

Image icon docx_cell_paddings.png25.22 KB
  • Status:Confirmed» Feedback Requested
  • Assigned:nobody» teodord


You did not upload here any JRXML so that we can see what fonts you are using. Are you sure that the fonts you are using in the report template exist and are available to the JVM on the machine where the report is actually generated?
Chances are that you are designing your report on Windows, using Windows fonts, but your server runs on Linux/Unix where there fonts do not exist and are replaced with some other default fonts having different metrics.

For pixel perfect results, you need to control your fonts and provide them to the server using JasperReports font extensions. Jaspersoft Studio can help with that.

Thank you,