Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 361623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:54:07+00:00 2026-05-12T12:54:07+00:00

I need to put images in my Jasper reports that match rows in a

  • 0

I need to put images in my Jasper reports that match rows in a database. I have the image data in proprietary archive files which I can easily extract in Java code. I need to know how to connect my Java code to the Jasper report to make the extraction process happen, something like BIRT’s onRowSets() method. (I need overview documentation about how the fill process works.)

If I define a POJO/bean data source, I won’t be able to easily use the database as well. Can I embed the necessary Java extraction code right in the XML? This example at the Jasper Assistant site seems to indicate that I can:

   <imageExpression class="java.io.File">
      <![CDATA[(new File($P{BaseDir}, "logo_"+$P{ReportCollecter}+".gif").exists()) 
         ? new File($P{BaseDir}, "logo_"+$P{ReportCollecter}+".gif") 
         : new File($P{BaseDir}, "logo_BLANK.gif")]]>
   </imageExpression>

Is that new File() actually Java code embedded in the XML? I’m willing to write code, but I can’t seem to find any complete class code examples (I think I want something like an extended image object).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T12:54:08+00:00Added an answer on May 12, 2026 at 12:54 pm

    By default, the current version of iReport (3.6.0) uses Groovy (a sort of Java scripting language) which has full access to any Java libraries in your classpath.

    All I had to do was write some code to extract the image from the archive and return an InputStream object (from a ByteArrayInputStream). Then I made a jar file and called the function from the Jasper jrxml file like so:

    <imageExpression class="java.io.InputStream">
       <![CDATA[
    com.mycompany.jasper.MyImageExtractor.getImage($F{IMAGE_URL}, $V{JasperVariable})
       ]]>
    </imageExpression>
    

    (You can also link to your code with the iReport GUI — set the “Image Expression” property for your new image to the line after the “CDATA”)

    For simpler Java coding needs, you can write simple Groovy code right in the XML of the report.

    Note that Jasper variables can be accessed in Groovy with $V{VariableName} and SQL Database columns can be accessed with $F{ColumnName}.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some PHP and HTML pages that need to access some files (images
I have several buttons that does operations on an image. I need to put
i need to put images into a json string.. first is that possible? i
I need to put some 3D images into PDF files, and PDF uses Universal
I need to put an image and text to WPF Ribbon Menu. I have
I have the following markup that I need to put the value of the
I have A MapView with multiple annotations. I need to put different images to
I have A MapView with Multiple annotations. But I need to put different images
I have many images that I need to place on a canvas over a
I am making a crawler that will put content(images) onto my website, i have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.