RenderTask ignoring referenced CSS file for HTML output? [message #242759] |
Thu, 14 June 2007 12:09  |
Eclipse User |
|
|
|
Hi there,
I have several reports using the new ability to reference a CSS file,
instead of importing it. We run and render reports separately in our
system, and it appears that the RenderTask ignores the CSS styles when
emitting HTML output (all working fine when the CSS is imported instead).
The resource path is set for the engine and the CSS resides in it
(actually the engine complains on the logs if there is garbage in the CSS
when it renders the report, so it must find it).
Is there any special option I need to set to make the task render the CSS
styles? (We are using embeddable output)
Thanks,
Olaf
|
|
|
|
|
Re: RenderTask ignoring referenced CSS file for HTML output? [message #242986 is a reply to message #242886] |
Fri, 15 June 2007 23:01   |
Eclipse User |
|
|
|
Originally posted by: jasonweathersby.alltel.net
Olaf,
Nothing appears to be wrong with the code you have.
I used the code below to do mine with rc2. If you look at the bug I
submitted I added a report and example style sheet. Could you try this
example. Use the css in the same folder as the report.
Jason
public class RenderTaskusecss {
public void runReport() throws EngineException
{
IReportEngine engine=null;
EngineConfig config = null;
try{
config = new EngineConfig( );
config.setBIRTHome("C:/birt/birt-runtime-2.2rc2/birt-runtime-2_2_0/ReportEngine ");
config.setLogConfig(null, Level.FINE);
config.setResourcePath("c:/temp/");
Platform.startup( config );
IReportEngineFactory factory = (IReportEngineFactory)
Platform.createFactoryObject(
IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
engine = factory.createReportEngine( config );
}catch( Exception ex){
ex.printStackTrace();
}
IReportDocument document = null;
//Open the report design
document =
engine.openReportDocument("output/resample/linkstyle.rptdocument ");
IRenderOption options = new RenderOption();
options.setOutputFormat("html");
options.setOutputFileName("output/resample/linkstyle.html");
if( options.getOutputFormat().equalsIgnoreCase("html")){
HTMLRenderOption htmlOptions = new HTMLRenderOption( options);
htmlOptions.setImageDirectory("output/image");
htmlOptions.setHtmlPagination(false);
//htmlOptions.setHtmlRtLFlag(true);
//htmlOptions.setEmbeddable(true);
}else{
PDFRenderOption pdfOptions = new PDFRenderOption( options );
//pdfOptions.setOption( IPDFRenderOption.FIT_TO_PAGE, new
Boolean(true) );
//pdfOptions.setOption( IPDFRenderOption.PAGEBREAK_PAGINATION_ONLY,
new Boolean(true) );
}
options.setActionHandler(new MyActionHandler());
IRenderTask task = engine.createRenderTask(document);
task.setRenderOption(options);
//task.setPageRange("5-7");
task.render();
task.close();
engine.destroy();
Platform.shutdown();
System.out.println("Finished");
}
/**
* @param args
*/
public static void main(String[] args) {
try
{
RenderTaskusecss ex = new RenderTaskusecss( );
ex.runReport();
}
catch ( Exception e )
{
e.printStackTrace();
}
}
}
Olaf Lenzmann wrote:
> Jason,
>
> thanks for the investigation. I had noticed that flute.jar and sac.jar
> had been removed from the report engine package somewhere between M6 and
> RC2. I added the ones I had from M6 so get around the ClassNotFound
> exceptions, and with this setup the reports can be rendered (no engine
> errors), but the output lacks all the styles from the external CSS.
> Replacing the jars with the ones from the current RC2 all-in-one didn't
> change that.
>
> Stupid question (sorry, but I'm a bit at a loss here): is the report is
> not only rendered, but do the styles appear correctly with the jar patch
> you have described? If so, could you have a brief look at my HTML render
> options below?
>
> Thanks again!
>
>
> Olaf
>
> =====
>
> private void setHTMLOptions( IRenderTask iRenderTask ) {
> // Set the HTML rendering options
> HTMLRenderOption options = new HTMLRenderOption();
>
> // Embeddable HTML
> options.setEmbeddable( true );
>
> // True of false doesn't seem to affect external CSS prob
> options.setEnableAgentStyleEngine( false );
>
> // Target format
> options.setOutputFormat( "html" );
>
> // The base URLs
> options.setBaseURL( birtConfiguration.getBaseURL() );
> options.setBaseImageURL( birtConfiguration.getBaseImageURL() );
>
> // The image dir
> options.setImageDirectory( birtConfiguration.getImageDirectory() );
>
> // We want SVG charts
> options.setSupportedImageFormats( "SVG" );
>
> // Action handler to create the links
> options.setActionHandler( this.servletActionHandler );
>
> // Set the image handler
> options.setImageHandler( new HTMLServerImageHandler() );
>
> // Apply the options
> iRenderTask.setRenderOption( options );
> }
>
>
>
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04160 seconds