【问题标题】:How to insert an image into a BIRT report with an URL properly?如何正确地将图像插入到带有 URL 的 BIRT 报告中?
【发布时间】:2014-08-12 12:39:49
【问题描述】:

我在 Eclipse 中使用 URL 将 Web 上的图像插入到 BIRT 报告中,但它不起作用。它在布局屏幕上显示一个红色的小 X,如果我选择运行/查看报告/作为 PDF,它会显示“无法访问此报告项的资源。”

这里有什么问题?我用谷歌搜索了几个小时,但一无所获。

提前感谢您的帮助!

【问题讨论】:

  • 对不起,我误解了你的问题,我会尽快编辑我的答案
  • 感谢您的回答。我按照你的建议做了,但仍然没有成功。我能够显示在 localhost 服务器上生成的图像,但不能显示来自网络的图像。原来代理设置是错误的。再次感谢邻居:)

标签: eclipse image url report birt


【解决方案1】:

尝试从您可以通过浏览器访问的网络添加图像。这样您就可以向自己保证通过 URI 访问您的图像没有问题。

例如添加这个网址

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

然后您会在报告中看到图片:

将您的图像作为嵌入图像包含在报告文件中的其他方式。在这个sn-p上

您可以查看如何将图像添加到您的报告文件中。完成后,将显示红色小图标的图像元素与嵌入的图像绑定。通过双击报告上的图像元素并从弹出的对话框中选择嵌入图像来执行此操作。

从第二个 sn-p 中,您可以看到您可以包含来自共享资源的图像,如果您有更多带有相同图像的报告,它会派上用场。例如您的客户的标志、您的公司标志等。

【讨论】:

    【解决方案2】:
    Using Dynamic Images in Birt Report
    

    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多