Jump to content
Changes to the Jaspersoft community edition download ×

How to change DPI


susula

Recommended Posts

Hi,

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.

 

Thanks,

Susula

Link to comment
Share on other sites

  • 2 months later...
  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

hi,

 

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

Link to comment
Share on other sites

Hi,

 

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.

 

Thanks,

Teodor

 

Link to comment
Share on other sites

Thanks for ur reply.

Please visit the link given below-

http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=57847

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 @-

http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=30573

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 ,

Sagar

 



Post Edited by csagar at 06/03/2009 15:28
Link to comment
Share on other sites

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 =
   builder.buildFromFile("c:/barcode4j.xml");

  BarcodeGenerator gen =
   BarcodeUtil.getInstance().createBarcodeGenerator(cfg);

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

  BitmapCanvasProvider provider =
   new BitmapCanvasProvider(
    301,
    BufferedImage.TYPE_BYTE_BINARY,
    true,
    0);

  gen.generateBarcode(provider, barcode);
  provider.finish();

return provider.getBufferedImage();

}

 public JRRenderable computeJasperBarcode(String barcode)
  throws
   ConfigurationException,
   JRException,
   IOException,
   SAXException,
   BarcodeException {
  return JRImageRenderer.getInstance(
   computeBarcode(barcode),
   JRRenderable.IMAGE_TYPE_PNG,
   JRImage.ON_ERROR_TYPE_ERROR);
 }

 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" >
     <reportElement
      x="211"
      y="113"
      width="25"
      height="25"
      key="image-9"
      positionType="FixRelativeToBottom"/>
     <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>
    </image>

 

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
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...