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)
Different behaviour between run/view Report/PDF and running testcase
jllivemont
I use birt 2.5.1 for a week.
I want to change the background report image with a script in the initialize of my rptdesign.
First i looked if i can set the image at runtime...
I set the background image like this:
reportContext.getReportRunnable().getDesignInstance().getMasterPage("SimpleMasterPage").getStyle().backgroundImage="file:////tmp/pdf/test.png";
This works fine when i use the menu Run/view Report/PDF.
When using a test case the pdf has no background...
I imagine it's a newbies question... But after some hours to make this working, i am a little bit frustrated...
Sorry if the thread overlap some other...
I haven't seen anything about this in the others.
Best regards.
Jean-Luc
Find more posts tagged with
Comments
mwilliams
Hi Jean-Luc,
When you say testcase, are you talking about deploying the report? Or something else? Let me know.
jllivemont
Here is my context.
We are using a jboss container.
I put the rptdesign in the birt.war and use an IReportEngine
Here is the code...
I guess the problem is around the birt parameters but i can't fix it...
The rptdesign in eclipse with run view report as pdf works well using an absolute path, a file:// and an external url to provide the background image.
Whe i use the folowing method to generate the report, i have no background.
private byte[] getRptWeb(ProtocolBirt protocolBirt, String clientId,
String rptDesignFileResource, String xmlDataFileResource,
RendererType rendererType) throws ClientProtocolException,
IOException, ColaException {
logger.debug("getRptWeb!!(ProtocolBirt protocolBirt=" +
protocolBirt + ", String clientId=" + clientId + ", String
rptDesignFileResource="
+ rptDesignFileResource + ", String xmlDataFileResource="
+ xmlDataFileResource + ", RendererType rendererType=" +
rendererType
+ ") - start");
// valid rendererType
if (!validRenderer(rendererType))
throw new ColaException("Illegal rendererType : " +
rendererType);
//
String url = "
http://localhost:8080/birt/frameset?__report="
; +
rptDesignFileResource + "&xmlDataFileResource=" +
xmlDataFileResource
+ "&Rendertype=" + rendererType.name() + "&languageType="
+ protocolBirt.getLanguageType().name() + "&folderId="
+ protocolBirt.getFolderId() + "&clientId=" + clientId +
"&__format=" + rendererType.name() + "&protocolBirtId="
+ protocolBirt.getId();
logger.debug("url = " + url);
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = null;
try {
httpget = new HttpGet(url);
} catch (Exception e) {
e.printStackTrace();
logger.error("Cound not build httpGet ", e);
throw new RuntimeColaException("Could not buid URL " + url);
}
// Execute HTTP request
logger.debug("executing request " + httpget.getURI());
HttpResponse response = httpclient.execute(httpget);
logger.debug("
");
logger.debug(url);
logger.debug("
");
logger.debug(response.getStatusLine());
logger.debug("
");
// Get hold of the response entity
HttpEntity entity = response.getEntity();
// If the response does not enclose an entity, there is no need
// to bother about connection release
if (entity != null) {
InputStream is = entity.getContent();
ByteArrayOutputStream nyteArrayOutputStream = new
ByteArrayOutputStream();
IOUtils.writeBuffersAndClose(is, nyteArrayOutputStream);
byte[] returnbyteArray = nyteArrayOutputStream.toByteArray();
logger.debug("getRptWeb!!(ProtocolBirt protocolBirt=" +
protocolBirt + ", String clientId=" + clientId
+ ", String rptDesignFileResource=" +
rptDesignFileResource + ", String
xmlDataFileResource=" + xmlDataFileResource
+ ", RendererType rendererType=" + rendererType + ") -
end");
return returnbyteArray;
}
throw new ColaException("Could not read buffer for " + protocolBirt);
}
private byte[] getRptWeb(ProtocolBirt protocolBirt, String
clientId, String rptDesignFileResource, String xmlDataFileResource,
RendererType rendererType) throws ClientProtocolException,
IOException, ColaException {
logger.debug("getRptWeb!!(ProtocolBirt protocolBirt=" +
protocolBirt + ", String clientId=" + clientId + ", String
rptDesignFileResource="
+ rptDesignFileResource + ", String xmlDataFileResource="
+ xmlDataFileResource + ", RendererType rendererType=" +
rendererType
+ ") - start");
// valid rendererType
if (!validRenderer(rendererType))
throw new ColaException("Illegal rendererType : " +
rendererType);
//
String url = "
http://localhost:8080/birt/frameset?__report="
; +
rptDesignFileResource + "&xmlDataFileResource=" +
xmlDataFileResource
+ "&Rendertype=" + rendererType.name() + "&languageType="
+ protocolBirt.getLanguageType().name() + "&folderId="
+ protocolBirt.getFolderId() + "&clientId=" + clientId +
"&__format=" + rendererType.name() + "&protocolBirtId="
+ protocolBirt.getId();
logger.debug("url = " + url);
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = null;
try {
httpget = new HttpGet(url);
} catch (Exception e) {
e.printStackTrace();
logger.error("Cound not build httpGet ", e);
throw new RuntimeColaException("Could not buid URL " + url);
}
// Execute HTTP request
logger.debug("executing request " + httpget.getURI());
HttpResponse response = httpclient.execute(httpget);
logger.debug("
");
logger.debug(url);
logger.debug("
");
logger.debug(response.getStatusLine());
logger.debug("
");
// Get hold of the response entity
HttpEntity entity = response.getEntity();
// If the response does not enclose an entity, there is no need
// to bother about connection release
if (entity != null) {
InputStream is = entity.getContent();
ByteArrayOutputStream nyteArrayOutputStream = new
ByteArrayOutputStream();
IOUtils.writeBuffersAndClose(is, nyteArrayOutputStream);
byte[] returnbyteArray = nyteArrayOutputStream.toByteArray();
logger.debug("getRptWeb!!(ProtocolBirt protocolBirt=" +
protocolBirt + ", String clientId=" + clientId
+ ", String rptDesignFileResource=" +
rptDesignFileResource + ", String
xmlDataFileResource=" + xmlDataFileResource
+ ", RendererType rendererType=" + rendererType + ") -
end");
return returnbyteArray;
}
throw new ColaException("Could not read buffer for " + protocolBirt);
}