assert reportDocument != null; assert pageNumber > 0 && pageNumber < reportDocument.getPageCount( );
	public ByteArrayOutputStream renderReport( HttpServletRequest request,			IReportDocument reportDocument, long pageNumber,			boolean masterPage, boolean svgFlag, List activeIds, Locale locale )			throws RemoteException	{		assert reportDocument != null;		assert pageNumber > 0 && pageNumber < reportDocument.getPageCount( );		ByteArrayOutputStream out = new ByteArrayOutputStream( );		// Create render task.		IRenderTask renderTask = null;		synchronized ( this.getClass( ) )		{			renderTask = engine.createRenderTask( reportDocument );		}		HashMap context = new HashMap( );		context.put( EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT,				createHTMLrenderContext( svgFlag, request.getServletPath( ) ) );		context.put( EngineConstants.APPCONTEXT_BIRT_VIEWER_HTTPSERVET_REQUEST,				request );		context.put( EngineConstants.APPCONTEXT_CLASSLOADER_KEY,				ReportEngineService.class.getClassLoader( ) );		renderTask.setAppContext( context );		// Render option		HTMLRenderOption setting = new HTMLRenderOption( );		setting.setOutputStream( out );		setting.setOutputFormat( IBirtConstants.RENDERFORMAT );		boolean isEmbeddable = false;		if ( IBirtConstants.SERVLET_PATH_FRAMESET.equalsIgnoreCase( request				.getServletPath( ) ) )			isEmbeddable = true;		setting.setEmbeddable( isEmbeddable );		setting.setInstanceIDs( activeIds );		setting.setMasterPageContent( masterPage );		setting.setActionHandle( new ViewerHTMLActionHandler( reportDocument,				pageNumber, locale, isEmbeddable ) );		renderTask.setRenderOption( setting );		renderTask.setLocale( locale );		// Render designated page.		try		{			renderTask.setPageNumber( pageNumber );			renderTask.render( );		}		catch ( BirtException e )		{			AxisFault fault = new AxisFault( );			fault.setFaultCode( new QName(					"ReportEngineService.renderReport( )" ) ); //$NON-NLS-1$			fault.setFaultString( e.getLocalizedMessage( ) );			throw fault;		}		catch ( Exception e )		{			AxisFault fault = new AxisFault( );			fault.setFaultCode( new QName(					"ReportEngineService.renderReport( )" ) ); //$NON-NLS-1$			fault.setFaultString( e.getLocalizedMessage( ) );			throw fault;		}		finally		{			renderTask.close( );		}		return out;	}