| Embeddable report and CSS [message #708048] |
Tue, 02 August 2011 07:35  |
Em Messages: 10 Registered: August 2011 Location: Portugal |
Junior Member |
|
|
I'm having an issue with the HTMLRenderOption.setEmbeddable option. I'm trying to embed a report in an existing web page and I'm using an external CSS style sheet in the report, the same CSS I'm using in the page.
When the setEmbeddable property is set to false the report generates an HTML output with the classes that are defined in the style sheet, something like '<div class="name">Entry 1</div>', but if I set the setEmbeddable property to true all the imported classes are removed from the generated HTML and the previous example becomes '<div>Entry 1</div>'.
Is this the normal behavior for BIRT? Shouldn't only the html and body tags be removed when I setEmbeddable to true?
I'm using BIRT 2.6 and the code I'm using is this:
ByteArrayOutputStream output = new ByteArrayOutputStream();
IHTMLRenderOption options = new HTMLRenderOption();
options.setOutputFormat(IHTMLRenderOption.OUTPUT_FORMAT_HTML);
options.setEmitterID(HTMLRenderOption.OUTPUT_EMITTERID_HTML);
options.setOutputStream(output);
options.setEmbeddable(true);
options.setBaseImageURL(getContext().getRequest().getContextPath() + "/images");
options.setImageDirectory(getContext().getServletContext().getRealPath("/images"));
options.setImageHandler(new HTMLServerImageHandler());
options.setMasterPageContent(false);
|
|
|
|
|
|
| Re: Embeddable report and CSS [message #708298 is a reply to message #708271] |
Tue, 02 August 2011 12:52   |
Jason Weathersby Messages: 9167 Registered: July 2009 |
Senior Member |

|
|
Here is my code. Attached is the report and css file.
import java.util.logging.Level;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EXCELRenderOption;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.EngineConstants;
import org.eclipse.birt.report.engine.api.EngineException;
import org.eclipse.birt.report.engine.api.HTMLRenderOption;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
import org.eclipse.birt.report.engine.api.PDFRenderOption;
public class RunAndRenderTask {
public void runReport() throws EngineException
{
IRunAndRenderTask task=null;
IReportEngine engine=null;
EngineConfig config = null;
try{
//System.setProperty("java.io.tmpdir", "c:/temp/test/testsampledb");
config = new EngineConfig( );
config.setLogConfig("c:/dwn", Level.INFO);
config.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY,
this.getClass().getClassLoader());
//config.getAppContext().put(EngineConstants.WEBAPP_CLASSPATH_KEY,
"C:\\work\\workspaces\\2.6.2workspaces\\BIRT
Metal\\APIs\\Reports\\eventjar.jar");
config.setBIRTHome("C:\\birt\\birt-runtime-2_6_2\\birt-runtime-2_6_2\\ReportEngine");
config.setLogConfig(null, Level.INFO);
Platform.startup( config );
IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject(
IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
engine = factory.createReportEngine( config );
IReportRunnable design = null;
//Open the report design
design = engine.openReportDesign("Reports/external.rptdesign");
task = engine.createRunAndRenderTask(design);
//task.setParameterValue("Top Count", (new Integer(5)));
//task.validateParameters();
HTMLRenderOption options = new HTMLRenderOption();
options.setImageDirectory("./");
options.setOutputFileName("output/resample/external.html");
options.setOutputFormat("html");
options.setEmbeddable(true);
//PDFRenderOption options = new PDFRenderOption();
//options.setOutputFileName("output/resample/fonttest.pdf");
//options.setSupportedImageFormats("PNG;GIF;JPG;BMP;SWF;SVG");
//options.setOutputFormat("pdf");
//EXCELRenderOption options = new EXCELRenderOption();
//options.setOutputFormat("xls");
//options.setOutputFileName("output/resample/customers.xls");
//options.setWrappingText(true);
task.setRenderOption(options);
task.run();
task.close();
engine.destroy();
}catch( Exception ex){
ex.printStackTrace();
}
Platform.shutdown( );
System.out.println("Finished");
}
/**
* @param args
*/
public static void main(String[] args) {
try
{
RunAndRenderTask ex = new RunAndRenderTask( );
ex.runReport();
System.exit(0);
}
catch ( Exception e )
{
e.printStackTrace();
}
}
}
Jason
On 8/2/2011 12:21 PM, Em wrote:
> Jason Weathersby wrote on Tue, 02 August 2011 11:56
>> I just tried this in 3.7 and in 2.6.2 and both worked. What version
>> are you using 2.6.0 or 2.6.1.
>>
>> Jason
>
>
>
> Jason, thank you for your reply, could you please show me the sample
> code you've used?
>
Jason Weathersby
BIRT Exchange
|
|
|
| Re: Embeddable report and CSS [message #708342 is a reply to message #708298] |
Tue, 02 August 2011 14:03  |
Em Messages: 10 Registered: August 2011 Location: Portugal |
Junior Member |
|
|
Jason, thank's again for your reply, I can't seem to find the problem and the only big difference I can find is that I'm using the report in a web application using ActionBean's and JSP's on JBOSS 6.0
The output HTML generated by BIRT is being embedded into a JSP.
I'm attaching the test project I'm working on together with a sample output HTML I'm getting in the browser. I've removed the jar's from BIRT to save size.
Could you be kind enough to take a look at it if you have the time.
Thank you.
Attachment: output.zip
(Size: 1.09MB, Downloaded 65 times)
[Updated on: Tue, 02 August 2011 14:08] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.02009 seconds