Jasperreports images are always blurry

A simple report containing only png.

Png dpi is 96, which looks pretty sharp. However, every time I export a report, be it .docx or pdf, only a terrible image appears.

I tried setting

net.sf.jasperreports.image.dpi 

up to 300 and up to 96

both in ireports and directly in the jrxml report as a property.

Nothing works.

exceptions

I have lost many days by going over this issue, but have not yet received an answer.

Update 1

I managed to trace the reason for this strange behavior in itext. It seems that he should do something about it.

Update 2

Here is the jrxml code

 <?xml version="1.0" encoding="UTF-8"?> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="carta_policia" pageWidth="612" pageHeight="792" columnWidth="572" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="fbda9a68-7549-438c-a8ad-b3aedaf0b2d4"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <property name="ireport.background.image" value="C:\Users\thou\workspace\cujillo\WebContent\resources\reports\fondo.png"/> <property name="ireport.background.image.properties" value="false,true,0.25,0,0,0,0,0,0"/> <property name="net.sf.jasperreports.image.dpi" value="96"/> <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false"> <defaultValueExpression><![CDATA["C:/Users/thou/workspace/cujillo/WebContent/resources/reports/"]]></defaultValueExpression> </parameter> <parameter name="R_RADICADO" class="java.lang.String"/> <parameter name="SUBREPORT_DATA_SOURCE" class="net.sf.jasperreports.engine.JRDataSource"/> <parameter name="R_ASUNTO" class="java.lang.String"/> <parameter name="R_LOCALIDAD" class="java.lang.String"/> <parameter name="R_IMAGE_RENDERER" class="net.sf.jasperreports.engine.JRRenderable" isForPrompting="false"/> <parameter name="R_PRINT_BACKGROUND" class="java.lang.String"/> <background> <band height="752"/> </background> <title> <band height="371" splitType="Stretch"> <image scaleImage="RealSize"> <reportElement uuid="dbadb500-4011-415b-bd98-4236532783c4" x="234" y="147" width="75" height="63"/> <imageExpression><![CDATA["C:\\Users\\thou\\workspace\\cujillo\\WebContent\\resources\\reports\\alcaldia mayor.png"]]></imageExpression> </image> <image scaleImage="Clip"> <reportElement uuid="ecf7dbe3-4369-41a8-ba49-db98ba5ef478" x="309" y="151" width="75" height="63"/> <imageExpression><![CDATA["C:\\Users\\thou\\workspace\\cujillo\\WebContent\\resources\\reports\\alcaldia mayor.jpg"]]></imageExpression> </image> </band> </title> <pageHeader> <band splitType="Stretch"/> </pageHeader> <columnHeader> <band splitType="Stretch"/> </columnHeader> <detail> <band height="104" splitType="Stretch"/> </detail> <columnFooter> <band splitType="Stretch"/> </columnFooter> <pageFooter> <band height="11" splitType="Stretch"/> </pageFooter> <summary> <band height="209" splitType="Stretch"/> </summary> </jasperReport> 
+7
source share
1 answer

Although we raised the DPI setting in our presentations, I implemented a custom exporter that exports charts as PowerPoint shapes and not bitmaps. At least for .docx you can implement something similar.

Before starting the form export classes, I tried using EMF ( 1 , 2 ) as the image format, but this is rather limited, for example, it does not insert fonts.

I have not looked further in the direction, but perhaps you can convert the intermediate SVG image to something (bitmap / vector) that can be embedded in .docx / .pdf.

Have you checked the images inside the .docx-Zip file? ... regular images are also blurry or just when they are displayed by Word / LibreOffice. And of course, the images should change after you change the DPI setting - if not, try putting jasperreports.properties in the classpath

+2
source

All Articles