Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » RenderTask ignoring referenced CSS file for HTML output?
RenderTask ignoring referenced CSS file for HTML output? [message #242759] Thu, 14 June 2007 16:09 Go to next message
No real name is currently offline No real nameFriend
Messages: 23
Registered: July 2009
Junior Member
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 #242845 is a reply to message #242759] Fri, 15 June 2007 03:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jasonweathersby.alltel.net

Olaf,

I am not certain what is happening here, but there appears to be a
classpath issue. I am using 2.2 rc2 and got css exceptions. I got it
to work by adding a two jars to the reportengine/lib directory. I also
added them to the classpath. I logged a bug for this:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=192794
It has the two libs I added. Note that these jars are in the plugins
directory, but for some reason the engine api is not loading them.

Jason

Olaf Lenzmann wrote:
> 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 #242886 is a reply to message #242845] Fri, 15 June 2007 07:28 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 23
Registered: July 2009
Junior Member
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 );
}
Re: RenderTask ignoring referenced CSS file for HTML output? [message #242986 is a reply to message #242886] Sat, 16 June 2007 03:01 Go to previous messageGo to next message
Eclipse UserFriend
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 );
> }
>
>
>
Re: RenderTask ignoring referenced CSS file for HTML output? [message #243038 is a reply to message #242986] Sun, 17 June 2007 11:30 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 23
Registered: July 2009
Junior Member
Jason,
Re: RenderTask ignoring referenced CSS file for HTML output? [message #243042 is a reply to message #242986] Sun, 17 June 2007 11:40 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 23
Registered: July 2009
Junior Member
Jason,

putting the CSS right next to the report design file solved the problem -
I had put it in the resources folder. Thanks for the hint!

However, having to to put the CSS there seems odd IMHO, because

* you need to replicate the CSS into all those folders with designs using
the CSS

* I had expected the RenderTask to bind the CSS styles, not the RunTask!
We have split report generation in our system into a backend job doing the
RunTask and a frontend doing the RenderTask (we generate & store report
documents and render them later in the frontend). I find now that I have
to put the CSS into the report design structures in the backend, plus we
lose the capability of changing the CSS later and re-rendering a report
with the changed L&F.

Is the current behavior the intended long-term solution, or is there a
chance that binding the styles may be postponed to the render task as some
point in the future?

Thanks again,

Olaf
Read just this... Re: RenderTask ignoring referenced CSS file for HTML output? [message #243046 is a reply to message #243042] Sun, 17 June 2007 12:15 Go to previous message
No real name is currently offline No real nameFriend
Messages: 23
Registered: July 2009
Junior Member
Jason,

forget all about it... We had an uncoordinated change of the frontend
resource folder path :-( - with that being corrected, the RenderTask picks
up the CSS from there fine and I don't have to place it next the report
design.

Thanks,

Olaf
Previous Topic:RenderOption for DOC, PPT and XLS
Next Topic:Europa Test
Goto Forum:
  


Current Time: Sun Jun 30 13:44:14 GMT 2024

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

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

Back to the top