Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » EmbeddedImage not added to report
EmbeddedImage not added to report [message #759934] Wed, 30 November 2011 15:38 Go to next message
js Missing name is currently offline js Missing name
Messages: 73
Registered: July 2009
Member
I am trying to add an image to a report:


    EmbeddedImage embeddedImage = StructureFactory.createEmbeddedImage();
    String constFile = "C:\\tests\\sample_img.png";
    byte[] imageByteArray;
    try {
      imageByteArray = FileUtils.readFileToByteArray(new File(constFile));
      embeddedImage.setType(DesignChoiceConstants.IMAGE_TYPE_IMAGE_PNG);
      embeddedImage.setName("name");
      embeddedImage.setData(imageByteArray);
      templateHandle.addImage(embeddedImage);
      templateHandle.saveAs("c:\\tests\\test.rptdesign");
    } catch (IOException e) {
      e.printStackTrace();
    } catch (SemanticException e) {
      e.printStackTrace();
    }


The code runs without any errors but when I open the test.rptdesign file the image is not there, why?
Re: EmbeddedImage not added to report [message #759938 is a reply to message #759934] Wed, 30 November 2011 15:57 Go to previous messageGo to next message
js Missing name is currently offline js Missing name
Messages: 73
Registered: July 2009
Member
So it needs to be referenced by an ImageHandle:

http://grepcode.com/file/repository.grepcode.com/java/eclipse.org/3.6.2/org.eclipse.birt.chart/examples/2.6.2/org/eclipse/birt/chart/examples/report/api/SalesReport.java
Re: EmbeddedImage not added to report [message #759981 is a reply to message #759934] Wed, 30 November 2011 19:10 Go to previous message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Embedded images are not shown unless they are used. Not certain that is
your issue, but have a look at the attached code. There is an addImage
method to add an embedded image. Once the image is added a Image report
item is created that uses the embedded image.

Jason

On 11/30/2011 10:38 AM, js wrote:
> I am trying to add an image to a report:
>
>
>
> EmbeddedImage embeddedImage = StructureFactory.createEmbeddedImage();
> String constFile = "C:\\tests\\sample_img.png";
> byte[] imageByteArray;
> try {
> imageByteArray = FileUtils.readFileToByteArray(new File(constFile));
> embeddedImage.setType(DesignChoiceConstants.IMAGE_TYPE_IMAGE_PNG);
> embeddedImage.setName("name");
> embeddedImage.setData(imageByteArray);
> templateHandle.addImage(embeddedImage);
> templateHandle.saveAs("c:\\tests\\test.rptdesign");
> } catch (IOException e) {
> e.printStackTrace();
> } catch (SemanticException e) {
> e.printStackTrace();
> }
>
>
> The code runs without any errors but when I open the test.rptdesign file
> the image is not there, why?
Previous Topic:Significance of engine parameters
Next Topic:Ad Hoc Reports -- Use BIRT or JSP??
Goto Forum:
  


Current Time: Wed Oct 01 22:25:07 GMT 2014

Powered by FUDForum. Page generated in 0.15692 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software