Are TOC and pagination related?

birtnewbie
edited February 11, 2022 in Analytics #1
I want to implement BIRT viewer like pagination functionality in the JSP pages of my webapp.
It is, however common knowledge that the BIRT engine will output HTML in a single file with repeated headers for every page.

I did some digging around and found a relation between TOC(Table of content) entries in the report and pagination. It is said the report viewer uses this technique to properly paginate HTML output. However, I am able to navigate my pages in the report viewer even though I dont have any TOC entries in my report(The TOC sidebar is blank).

What exactly is the technique used by the BIRT viewer to break up html that way?
How can I achieve this using the Report Engine API?

Thanks in advance,
birtnewbie.

Comments

  • JasonW
    edited December 31, 1969 #2
    The BIRT Viewer does this by first doing a run task and then a render task. As part of the render task you can set a page number or a range of pages.

    public class RenderTask {

    public void runReport() throws EngineException
    {

    IReportEngine engine=null;
    EngineConfig config = null;

    try{

    config = new EngineConfig( );
    config.setBIRTHome("C:birtbirt-runtime-2_2_1birt-runtime-2_2_1ReportEngine");
    config.setLogConfig(null, Level.FINE);
    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/mcb.rptdocument");

    IRenderOption options = new RenderOption();
    options.setOutputFormat("html");

    //options.setOutputStream(arg0)
    options.setOutputFileName("output/resample/mcb.html");


    if( options.getOutputFormat().equalsIgnoreCase("html")){
    HTMLRenderOption htmlOptions = new HTMLRenderOption( options);
    htmlOptions.setImageDirectory("output/image");
    htmlOptions.setHtmlPagination(false);
    //set this if you want your image source url to be altered
    htmlOptions.setBaseImageURL("http://myhos/prependme?image=");
    htmlOptions.setHtmlRtLFlag(false);
    htmlOptions.setEmbeddable(false);
    }else if( options.getOutputFormat().equalsIgnoreCase("pdf") ){

    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("1-3");
    task.setPageNumber(3);
    task.render();
    task.close();
    engine.destroy();
    Platform.shutdown();
    System.out.println("Finished");

    Jason