Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Image not showing in PDF(Image not showing in PDF)
Image not showing in PDF [message #789912] Fri, 03 February 2012 15:12 Go to next message
Eric W is currently offline Eric W
Messages: 29
Registered: November 2009
Junior Member
Hello, I am using a script to add an image to a report via URL. It works correctly in preview mode and it works in the web viewer. However, when I click "Export PDF" or any other format(doc,ppt, etc...) the image does not render.

My script in my .rptdesign file is

beforeFactory

importPackage(Packages.javax.imageio);
importPackage(Packages.java.io);
importPackage(Packages.java.net);
importPackage(Packages.java.lang);
importPackage(Packages.org.apache.commons.codec.binary)
importPackage(Packages.java.lang);

var myurl = URL("http://tomcat.apache.org/images/tomcat.gif");
var img = ImageIO.read(myurl);
bas = new ByteArrayOutputStream();
ImageIO.write(img, "jpg", bas);
bas.flush();

encodedimga = Base64.encodeBase64(bas.toByteArray());
encodedimg = new String( encodedimga, "utf-8"); 
bas.close();
imgsrc = "data:image/jpg;base64,"+encodedimg+"\"";


I have a html text element with a value of

<img src=<VALUE-OF>imgsrc</VALUE-OF> +" alt="what ever" />


Again this only renders in the web viewer not as any other format.

I am using web viewer 3.7

Thank you for any help you can provide.
Re: Image not showing in PDF [message #789939 is a reply to message #789912] Fri, 03 February 2012 15:49 Go to previous messageGo to next message
Eric W is currently offline Eric W
Messages: 29
Registered: November 2009
Junior Member
I did correct the type to gif, still same problem.

ImageIO.write(img, "jpg", bas); to
ImageIO.write(img, "gif", bas);

Re: Image not showing in PDF [message #789949 is a reply to message #789939] Fri, 03 February 2012 16:01 Go to previous message
Alessio Pollero is currently offline Alessio Pollero
Messages: 66
Registered: August 2011
Member
Set the image as dynamic image and then on the onRender script of the image itself write some code as the following :

importPackage(Packages.java.io);
importPackage(Packages.java.lang);
importPackage(Packages.java.net);
importPackage(Packages.javax.imageio);



//Image at url
var myurl = new Packages.java.net.URL("http://tomcat.apache.org/images/tomcat.gif");

var img = ImageIO.read(myurl);
var bas = new ByteArrayOutputStream();
ImageIO.write(img, "gif", bas);
this.data = bas.toByteArray();
}
Previous Topic:Customization BIRT Report Viewer
Next Topic:how to set data set column as label for value series in a pie chart
Goto Forum:
  


Current Time: Tue Oct 21 10:37:09 GMT 2014

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

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