assertTrue( "Render " + fileName + " to html failed. " + pageRange, htmlFile.exists( ) ); assertTrue( "Render " + fileName + " to html failed. " + pageRange, htmlFile.length( ) != 0 );
assertTrue( "Render " + fileName + " to html failed. ", htmlFile.exists( ) ); assertTrue( "Render " + fileName + " to html failed. ", htmlFile.length( ) != 0 );
	protected void renderReport( String fileName, String pageRange )	{		report_design = inputPath + fileName + ".rptdesign";		report_document = outputPath + fileName + "_reportdocument";		IRenderTask task;		// create directories to deposit output files		createDir( fileName );		try		{			createReportDocument( report_design, report_document );			// open the document in the archive.			reportDoc = engine.openReportDocument( report_document );			// Set IRenderOption			IRenderOption htmlRenderOptions = new HTMLRenderOption( );			IRenderOption pdfRenderOptions = new HTMLRenderOption( );			HTMLRenderContext renderContext = new HTMLRenderContext( );			renderContext.setImageDirectory( "image" );			HashMap appContext = new HashMap( );			appContext.put( EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT,					renderContext );			htmlRenderOptions.setOutputFormat( "html" );			pdfRenderOptions.setOutputFormat( "pdf" );			htmlRenderOptions.getOutputSetting( ).put(					HTMLRenderOption.URL_ENCODING, "UTF-8" );			pdfRenderOptions.getOutputSetting( ).put(					HTMLRenderOption.URL_ENCODING, "UTF-8" );			int i_bookmark = -1;			if ( pageRange != null )			{				i_bookmark = pageRange.indexOf( "bookmark_" );			}			if ( i_bookmark == -1 )			{				if ( pageRange != null && pageRange.equals( "no" ) )				{					/* set page number 1 and then render the first page */					// render html output					outputFileName = outputPath + fileName + "/html/page1"							+ ".html";					removeFile( outputFileName );					htmlRenderOptions.setOutputFileName( outputFileName );					task = engine.createRenderTask( reportDoc );					task.setLocale( Locale.ENGLISH );					task.setAppContext( appContext );					task.setRenderOption( htmlRenderOptions );					task.setPageNumber( 1 );					task.render( );					task.close( );					File htmlFile = new File( outputFileName );					assertTrue( "Render " + fileName + " to html failed. ",							htmlFile.exists( ) );					assertTrue( "Render " + fileName + " to html failed. ",							htmlFile.length( ) != 0 );					// render pdf output					outputFileName = outputPath + fileName + "/pdf/page1"							+ ".pdf";					removeFile( outputFileName );					pdfRenderOptions.setOutputFileName( outputFileName );					task = engine.createRenderTask( reportDoc );					task.setLocale( Locale.ENGLISH );					task.setAppContext( appContext );					task.setRenderOption( pdfRenderOptions );					task.setPageNumber( 1 );					task.render( );					task.close( );					File pdfFile = new File( outputFileName );					assertTrue( "Render " + fileName + " to pdf failed. ",							pdfFile.exists( ) );					assertTrue( "Render " + fileName + " to pdf failed. ",							pdfFile.length( ) != 0 );				}				else				{					/* set page range and then render according to range */					// render html output					outputFileName = outputPath + fileName + "/html/page"							+ pageRange + ".html";					removeFile( outputFileName );					htmlRenderOptions.setOutputFileName( outputFileName );					task = engine.createRenderTask( reportDoc );					task.setLocale( Locale.ENGLISH );					task.setAppContext( appContext );					task.setRenderOption( htmlRenderOptions );					task.setPageRange( pageRange );					task.render( );					task.close( );					File htmlFile = new File( outputFileName );					if ( pageRange != null							&& ( pageRange.equals( "0" ) || pageRange									.equals( "abc" ) ) )					{						assertFalse( htmlFile.exists( ) );					}					else					{						assertTrue( "Render " + fileName + " to html failed. "								+ pageRange, htmlFile.exists( ) );						assertTrue( "Render " + fileName + " to html failed. "								+ pageRange, htmlFile.length( ) != 0 );					}					// render pdf output					outputFileName = outputPath + fileName + "/pdf/page"							+ pageRange + ".pdf";					removeFile( outputFileName );					pdfRenderOptions.setOutputFileName( outputFileName );					task = engine.createRenderTask( reportDoc );					task.setLocale( Locale.ENGLISH );					task.setAppContext( new HashMap( ) );					task.setRenderOption( pdfRenderOptions );					task.setPageRange( pageRange );					task.render( );					task.close( );					File pdfFile = new File( outputFileName );					if ( pageRange != null							&& ( pageRange.equals( "0" ) || pageRange									.equals( "abc" ) ) )					{						assertFalse( pdfFile.exists( ) );					}					else					{						assertTrue( "Render " + fileName + " to pdf failed. "								+ pageRange, pdfFile.exists( ) );						assertTrue( "Render " + fileName + " to pdf failed. "								+ pageRange, pdfFile.length( ) != 0 );					}				}			}			else			{				String bookmark = pageRange.substring( 9 );				// render html output				outputFileName = outputPath + fileName + "/html/bookmark_"						+ bookmark + ".html";				removeFile( outputFileName );				htmlRenderOptions.setOutputFileName( outputFileName );				task = engine.createRenderTask( reportDoc );				task.setLocale( Locale.ENGLISH );				task.setAppContext( appContext );				task.setBookmark( bookmark );				task.setRenderOption( htmlRenderOptions );				task.render( );				task.close( );				File htmlFile = new File( outputFileName );				assertTrue( "Render " + fileName + " to html failed. "						+ pageRange, htmlFile.exists( ) );				assertTrue( "Render " + fileName + " to html failed. "						+ pageRange, htmlFile.length( ) != 0 );				// render pdf output				outputFileName = outputPath + fileName + "/pdf/bookmark_"						+ bookmark + ".pdf";				removeFile( outputFileName );				pdfRenderOptions.setOutputFileName( outputFileName );				task = engine.createRenderTask( reportDoc );				task.setLocale( Locale.ENGLISH );				task.setAppContext( appContext );				task.setBookmark( bookmark );				task.setRenderOption( pdfRenderOptions );				task.render( );				task.close( );				File pdfFile = new File( outputFileName );				assertTrue( "Render " + fileName + " to pdf failed. "						+ pageRange, pdfFile.exists( ) );				assertTrue( "Render " + fileName + " to pdf failed. "						+ pageRange, pdfFile.length( ) != 0 );			}			task.close( );					}		catch ( Exception e )		{			e.printStackTrace( );			assertTrue( "Render " + fileName + " failed. "					+ e.getLocalizedMessage( ), false );		}	}