How to insert an image into a BIRT report with an

2019-07-16 07:49发布

I inserted an image from the web into a BIRT report using an URL in Eclipse, but it doesn't work. It displays a little red X on the Layout screen, and if I choose Run/View Report/As PDF it says "The resource of this report item is not reachable."

What is the problem here? I have googled for hours but found nothing.

Thanks in advance for any help!

2条回答
叛逆
2楼-- · 2019-07-16 07:57

Try adding image from web which you can access via your browser. That way you'll assure yourself you don't have problems with accessing your image via URI.

For example add this URL

http://hajduk.hr/sadrzaj/slike-za-vijesti/640x320/2010-06-08-jerkovic.jpg

and you see the image in your report:

enter image description here

Other way to include your image as embedded image in report file. On this snippet

enter image description here

you can see how to add image to your report file. After you do it, bind your image element which displays little red icon with your embedded image. Do this by double clicking the image element on report and from dialogue which will popup chose embedded image.

enter image description here

From this second snippet, you see that you can include image from Shared resources which comes in handy if you have more reports with same image on it. For instance logo of your client, your company logo etc.

查看更多
Summer. ? 凉城
3楼-- · 2019-07-16 07:57
Using Dynamic Images in Birt Report

Creating Dynamic Image

Pointing to image logo with Blob datatype

Steps:

1) Create class

class BirtReport {
   public byte[] imageLogo;
}

2) Convert your image into bytes

public byte[] readImagesBytes(String url) {
     byte[] imageBytes = new byte[5024];
     try {
            // Apachae IOUtils
            imageBytes = IOUtils.toByteArray(new URL(url));
     } catch (IOException e) {
            imageBytes = new byte[0];
     }

     return imageBytes;
}

BirtReport birtReport = new BirtReport();
birtReport.imageLogo = readImagesBytes("http://www.underconsideration.com/brandnew/archives/google_2015_logo_detail.png");


3) In the Birt Report create Data Set

   BirtReportData with Blog type of imageLogo


Create the Data Set with imageLogo of Blog Data Type in Birt Report. Convert the image into bytes from server side. 
I have solved "The resource of this report item is not reachable" error
查看更多
登录 后发表回答