Embeddable report and CSS [message #708048] |
Tue, 02 August 2011 07:35  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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?
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.06632 seconds