tomkast Posted March 8, 2010 Share Posted March 8, 2010 hello, using ireports3.6.1, pdf preview, with jpeg image tag like this:<image scaleImage="RealSize" hAlign="Center" vAlign="Middle"> <reportElement positionType="Float" x="2" y="62" width="549" height="146"> <printWhenExpression><![CDATA[$V{PAGE_NUMBER} == 1]]></printWhenExpression> </reportElement> <imageExpression class="java.lang.String"><![CDATA[$P{wo_image_path}]]></imageExpression> </image> the image comes out too big in PDF (about 10% bigger than original). any ideas on how to keep image in exactly (pixel-perfect) size of original jpeg? thanks!tom Link to comment Share on other sites More sharing options...
tomkast Posted March 8, 2010 Author Share Posted March 8, 2010 note: if pdf is at 65% size, then image in exported report is correct, original size... fyi, client needs image in report to be exactly the same size as original for production staff to use sewing embroidery matching image.... Link to comment Share on other sites More sharing options...
tomkast Posted March 8, 2010 Author Share Posted March 8, 2010 here is image and pdf -- as you can see pdf image is bigger then source image. this is done with "RealSize" setting on image tag. a lot of similar threads but no answers found. one idea would be to set the width and height of image tag dynamically. can this be done with a parameter? Link to comment Share on other sites More sharing options...
tomkast Posted March 9, 2010 Author Share Posted March 9, 2010 Really need some help here -- completely lost -- not an "image guy". Reproduce by simply using ireports 3.6.1 and see the internal preview -- images with "Real Size" set still expand to the size of the image tag... am i out to lunch??? :-) ok -- don't answer that.... Link to comment Share on other sites More sharing options...
tomkast Posted March 10, 2010 Author Share Posted March 10, 2010 attention teodord ----please stop me if i am of track --what i am going to do to get a dynamic image into a pdf, where as the image dimensions remain exactly the same as the original image, is to 1) use java to get the x and y pixel dimensions of image2 ) parse the JRXML and change the height and width3) recompile the JRXML into .jasper4) run the reportif this is not the right way, even if we need to pay some money, _please_ reply with the solution. but if this is the right solution, no problem at all, not a lot of code, and it will not impact performance to any noticable degree. Link to comment Share on other sites More sharing options...
tomkast Posted March 11, 2010 Author Share Posted March 11, 2010 this works: Code: BufferedImage img = ImageIO.read(new File(wo_image_path)); height = img.getHeight(); width = img.getWidth(); jasperSubDesign = JasperManager.loadXmlDesign(context.getRealPath("/WEB-INF/reports/decoration_sheet_header.jrxml")); JRDesignImage image = (JRDesignImage)jasperSubDesign.getPageHeader().getElementByKey("wo_image"); image.setX(3); image.setY(69); image.setHeight(new Long(height - Math.round(height*.35)).intValue()); image.setWidth(new Long(width - Math.round(width*.35)).intValue()); JasperCompileManager.compileReportToFile(jasperSubDesign, context.getRealPath("/WEB-INF/reports/decoration_sheet_header.jasper")); Link to comment Share on other sites More sharing options...
tomkast Posted June 30, 2014 Author Share Posted June 30, 2014 I need to deal with this again. The problem is that the application has to deal with images of various resolutions. For example, a 96 PPI JPEG image comes out too big in Jasper Reports. Interesting, other applications can handle this, I am no expert, but I would guess that applications look at the image properties, see the PPI, and render the image accordingly. Unless I am missing something, you can't just choose 72 DPI and render/print all images at that resolution, some will be too big, some too small. So I am guessing I need to write a renderer and makes this calculation? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now