#1 2016-06-16 10:06:14

JohnZa
Member
Registered: 2016-06-16

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

Offline

#2 2016-06-16 12:02:15

Thomas Davies
datenwerke
Registered: 2016-05-18

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

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/ja … s-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

Offline

Board footer

Powered by FluxBB