Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Programmatically add image to report at runtime
David91
<p>Hi,</p>
<p> </p>
<p>is there any way to add an image programmatically via Java API to the report at runtime? The image source should be dynamically as it is a custom image.</p>
<p> </p>
<p>I tried it with creating an image and setting the data via Java API like this</p>
<pre class="_prettyXprint">
ReportDesignHandle rdh = (ReportDesignHandle)design.getDesignHandle();
EmbeddedImage eImg = new EmbeddedImage();
eImg.setData(bytes);
rdh.addImage(eImg);</pre>
<p>but it won't work.</p>
<p> </p>
<p>TiA</p>
Find more posts tagged with
Comments
mwilliams
Have you tried passing the image through the application context and accessing it inside the report design?
David91
<p>I've added the image with the ImageHandle object but setting x and y has no effects on the displaying of the image in the pdf file</p>
<div>
<pre class="_prettyXprint">
ReportDesignHandle rdh = (ReportDesignHandle)design.getDesignHandle();
ElementFactory fac = rdh.getElementFactory();
ImageHandle imgHandle = fac.newImage("barcode");
imgHandle.setFile("\"C:/Users/dl/Desktop/sample-barcode2.png\"");
imgHandle.setWidth("100px");
imgHandle.setHeight("50px");
imgHandle.setX(500);
imgHandle.setY(100);
rdh.getBody().add(imgHandle);</pre>
</div>
<p>Regards</p>