I can create the pdf file and I can open the pdf file it but my browser
screen does not finish refreshing so end up with a white screen I create the
Birt engine in the application bean with has an application scope
I can create a HTML report and open it in a seperate browser window if I
have to but I would rather have a PDF This is the code I am using

****application bean****
try{
     config = new EngineConfig();
     config.setEngineHome(
"C:\\birtruntime\\birt-runtime-2_2_0\\ReportEngine" );
     config.setLogConfig("c:/birt/logs", Level.FINE);
     Platform.startup( config );
     IReportEngineFactory factory = (IReportEngineFactory) Platform
        .createFactoryObject(  
IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
     engine = factory.createReportEngine( config );
     engine.changeLogLevel( Level.WARNING );
    }catch( Exception ex){
        ex.printStackTrace();
    }
I then have a action that uses the engine
public String birtReport2(){
                System.out.println("entering birtReport2");
                HashMap<String, Integer> parameters = new HashMap<String, 
Integer>();
                 String name = "requestid";
                          Integer pvalue = new Integer(4);
                     parameters.put(name, 9667);
                 FacesContext faces = FacesContext.getCurrentInstance();
                HttpServletResponse resp = (HttpServletResponse) 
faces.getExternalContext
                                                               
().getResponse();
                HttpServletRequest req=(HttpServletRequest)
faces.getExternalContext().getRequest();
                resp.setContentType( "application/pdf" ); 
                resp.setHeader ("Content-Disposition","attachment; 
filename=/output.pdf");  
                ServletContext sc = req.getSession().getServletContext();
                PDFRenderContext renderContext = new PDFRenderContext();
                HashMap<String, PDFRenderContext> contextMap = new 
HashMap<String,  
                                                                                
                       
PDFRenderContext>();
                 contextMap.put( EngineConstants.APPCONTEXT_PDF_RENDER_CONTEXT, 
                                                 renderContext );
                    IReportRunnable design;
                 try
                 {
                  //Open report design
                 design =
FacesUtils.getApplicationBean().getEngine().openReportDesign(sc.getRealPath
                                    
("app/birt/compliancerecycle.rptdesign")); 
                 //create task to run and render report
                 IRunAndRenderTask task = 
FacesUtils.getApplicationBean().getEngine()
                                                               
.createRunAndRenderTask( design );  
                 task.setAppContext( contextMap );
                 //set output options
                 PDFRenderOption options = new PDFRenderOption();
                  
//options.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_HTML);
                 options.setOutputFormat(PDFRenderOption.OUTPUT_FORMAT_PDF);
                 // options.setOutputFileName(filename);
                
//System.out.println("options.getOutputFileName()"+options.getOutputFileName());
                 options.setOutputFormat("pdf");
                     options.setOutputStream(resp.getOutputStream());
                     task.setRenderOption(options);
                 //run report
                 task.run();
                 task.close();
                 faces.responseComplete();
                 }catch (Exception e){
                            e.printStackTrace();
                 }
                 System.out.println("leaving birtReport2");
                return "null";
        }
I have also tried it with the HTMLRenderContext and  HTMLRenderOption with
the same results

-- 
View this message in context: 
http://www.nabble.com/JSF-render-BIRT-open-PDF-file-tf4238279.html#a12059402
Sent from the MyFaces - Users mailing list archive at Nabble.com.

Reply via email to