Jump to content

Wrong image size in pdf


hovendal

Recommended Posts

Hi All,

 

I have searched the forum  and found an earlier post with approximately this question - with no replies :(

I have a jasper report with a pixel width of 497. So I have designed a nice image to be in the title band, with width 497, and a height of 50 px.  Unfortunately the image is not as wide as it should be, when I generate the pdf. It is in fact ALOT smaller... If i try to use "scaleImage" it scales it allright, but ofcourse, it is then very grainy - and it streches both width and height...

I read the image with:

<imageExpression class="java.io.InputStream"><![CDATA[getClass().getResourceAsStream("/reportlogo.jpg")]]>

Could this have any impact?

What do you guys do, when you need an image, that fits the entire width of the page.

 

Please help! :)

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Actually, I can see now, that it is not only the image that is wrong -. the PDF file is not at all following my width specifications.

For instance: I have a colounm header with width 497, which in pdf is 721 px wide - viewed in 100% mode in my reader. My image is in the pdf actually smaller - only width 457.

I am pretty confused by now, can someone please explain what and how the widths I specify in my JRXML is interpreted?!

Link to comment
Share on other sites

Hi,

 

How do you measure your PDF in pixels? Are you actually counting the pixels on screen?

 

JR uses the default Java resolution of 72 pixels per inch, for all measures. But screens these days have 96 pixels per inch.

 

So what I'm saying is that at 100% zoom ratio it is obvious that the image would look a bit scaled, because its pixels are drawn a little larger.

 

Anyway, maybe I don't fully understand your problem, but in that case, you should post here some files to show us the problem.

 

Thank you,

Teodor

 

Link to comment
Share on other sites

Yes, I am in fact "counting" the pixels... Using a tool thoug, but still...

I am thinking that it might has something to do with how many pixels per inch, but what to do then... I just need to know what width my image needs to have to correspond to my column width... Files attached..

1 pdf with image with width 497 = column width in report

1 pdf with image with width 761 = measured width of column

 

Both pdf's include a blue bar with the supposed column width of 497 pixels...

 

Report code included as well...

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="RoomListOneFreq" 	pageWidth="595" 	pageHeight="842" 	columnWidth="497" 	leftMargin="70" 	rightMargin="28" 	topMargin="28" 	bottomMargin="28">		<!-- Imports -->		<import value="net.sf.jasperreports.engine.*"/>	<import value="java.util.Set"/>	<import value="net.sf.jasperreports.engine.data.*"/>			<!-- Title band -->	<title>		<band height="30">			<image >				<reportElement x="0" y="0" width="497" height="30"/>							<imageExpression class="java.lang.String"><![CDATA["reportlogo.jpg"]]></imageExpression>							</image>		</band>	</title>		<!-- Page header band -->	<pageHeader>		<band height="17" splitType="Stretch">			<rectangle>				<reportElement x="0" y="0" width="497" height="15" backcolor="#002D56" forecolor="#002D56"/>			</rectangle>		</band>	</pageHeader></jasperReport>
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...