How to change DPI


is there a way how to change DPI for report and print? 

I found in code something like this:

  * The DPI of the generated report.
 public static final int REPORT_RESOLUTION = 72;


Why is REPORT_RESOLUTION final? Like there's no other.




susula's picture
Joined: Mar 17 2009 - 5:08am
Last seen: 14 years 6 months ago

4 Answers:



I'm facing same problem. I also want to chnge that resolution Maybe through code. But I could not locate this constant. Could you please tell me the name of the class file where you found it out ??

Thanks in advance!!


csagar's picture
Joined: Feb 18 2009 - 12:08am
Last seen: 14 years 7 months ago



There is no point in changing that constant. Things are not as easy as you might think.

You have to explain in more detail, why would you want to change the default resolution of 72 dots per inch, which by the way is also the default resoulution in Java. What do you think you'll be able to achieve doing that?

Is this about image, about the printer, or what?


This constant resolution of 72 simply allow us to have a precise and reliable coordinate system. Nothing more. Changing this would have no effect in the quality of the documents.





teodord's picture
Joined: Jun 30 2006 - 9:00am
Last seen: 2 hours 36 min ago

Thanks for ur reply.

Please visit the link given below-

My problem-

I have to deploy my application on a web server so I need to export my reports as HTML.

When a chart is rendered its rendered as .png image. This image is very much distorted.I referred to your post @-

There you have mentioned about using 300 DPI or more for better quality of image.

For your referrence I have attached the screenshot of the rendered report.

 You can see that the lines ,legends are distorted. Also the colors are not looking that good.As mentioned in your post I thought changing the resolution would help me.


If you could provide a better solution I will be thankful to you.


Thanks ,



Post Edited by csagar at 06/03/2009 15:28
csagar's picture
Joined: Feb 18 2009 - 12:08am
Last seen: 14 years 7 months ago

i have encounter the similar printing a 300 dpi barcode on my jasper report


My problem is resolved as follow: (i use barcode4j as my barcode library


I have written a class called DataMatrixUtility with the code

public BufferedImage computeBarcode(String barcode){

//can be ignored barcode generation code start 
  DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  Configuration cfg =

  BarcodeGenerator gen =

//can be ignored barcode generation code end
// following line encode and return the buffered image into 301 dpi bufferedimage

  BitmapCanvasProvider provider =
   new BitmapCanvasProvider(

  gen.generateBarcode(provider, barcode);

return provider.getBufferedImage();


 public JRRenderable computeJasperBarcode(String barcode)
   BarcodeException {
  return JRImageRenderer.getInstance(

 In my JRXML, i write (only important part is listed) 


<!-- import the barcode class i written -->

 <import value="com.barcode.*" />


    <image vAlign="Top" isUsingCache="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
     <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
     <graphicElement stretchType="NoStretch"/>
     <imageExpression class="net.sf.jasperreports.engine.JRRenderable"><![CDATA[DataMatrixUtility.getInstance().computeJasperBarcode("ABCDEFGHI")]]></imageExpression>


I guess the default idea of JRXML converting the image into bufferedImage and then net.sf.jasperreports.engine.JRRenderable. Via this way, DPI of picture cannot be adjusted. My way is to control the DPI during conversion of bufferedImage


Hope my information can help u 

Post Edited by zol777 at 06/04/2009 06:48
zol777's picture
Joined: Sep 1 2006 - 1:38pm
Last seen: 8 years 2 months ago