Creating a URL from an ID and inserting an image from a url

I’m pretty new to Jasper ReportStudio and am creating numerous reports using this fabulous tool.

Right now I’m in the process of creating a report that will include images imported from a web server via HTTP
The image ID is in the format of an integer and is stored on a MySQL server combined with its date

eg
ID DATE
136347339 2016-06-11 09:19:05

The url is created using the following function in ASP.NET

function getAutoGeneratedImageFile(sightingid, seperator)
dim f, n, p
f = “”
for n = 0 to 7 'Eight bytes in a long int (each byte will be used as a folder name)
p = cdbl(sightingid) mod 256 'Due to the possible large scale of the uid, we have to use these functions
f = seperator & p & f
sightingid = sightingid \ 256
next
f = f & “.jpg”
getAutoGeneratedImageFile = f
end function

URL generated ends up in the form
HTTP://Imageserver/images/0/0/0/0/8/32/126/203.jpg

Can anyone help me out with adding a function in Jasper to create the URL and insert the image?

Regards,

John

Hi John,

you can add custom functions to Jasper, but you would need to implement them in Java. A starting tutorial on how this may be done is given in

http://community.jaspersoft.com/wiki/jaspersoft-studio-expression-editor-how-extend-it-and-contribute-your-own-functions-part-2-0

Alternatively you could probably do the computation with a JasperReports expression. This could be something along the lines

($F{ID} % 256) + "/" + (($F{ID}/256) % 256) + "/" + (($F{ID}/(256*2)) % 256) + "/" + (($F{ID}/(256*3)) % 256) ... ... + ".jpg"

Hope this helps.

Thomas