本文整理汇总了Java中org.eclipse.birt.report.engine.api.HTMLRenderOption.setOutputFormat方法的典型用法代码示例。如果您正苦于以下问题:Java HTMLRenderOption.setOutputFormat方法的具体用法?Java HTMLRenderOption.setOutputFormat怎么用?Java HTMLRenderOption.setOutputFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.birt.report.engine.api.HTMLRenderOption
的用法示例。
在下文中一共展示了HTMLRenderOption.setOutputFormat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runAndRender
import org.eclipse.birt.report.engine.api.HTMLRenderOption; //导入方法依赖的package包/类
/**
* Run and render the report, and return the render result.
*
* @param designFile
* @return render result.
* @throws EngineException
* @throws IOException
*/
protected String runAndRender( String designFile ) throws EngineException,
IOException
{
IRunAndRenderTask runAndRenderTask = createRunAndRenderTask( designFile );
HTMLRenderOption options = new HTMLRenderOption( );
ByteArrayOutputStream out = new ByteArrayOutputStream( );
options.setOutputStream( out );
options.setOutputFormat( "html" );
options.setHtmlPagination( true );
runAndRenderTask.setRenderOption( options );
runAndRenderTask.run( );
runAndRenderTask.close( );
String result = new String( out.toByteArray( ) );
out.close( );
return result;
}
示例2: renderPage
import org.eclipse.birt.report.engine.api.HTMLRenderOption; //导入方法依赖的package包/类
protected String renderPage( IReportDocument doc, long pageNo )
throws Exception
{
ByteArrayOutputStream buffer = new ByteArrayOutputStream( );
assertTrue( pageNo <= doc.getPageCount( ) );
IRenderTask renderTask = engine.createRenderTask( doc );
try
{
HTMLRenderOption options = new HTMLRenderOption( );
options.setOutputFormat( "html" );
options.setOutputStream( buffer );
renderTask.setRenderOption( options );
renderTask.setPageNumber( (long) pageNo );
renderTask.render( );
List errors = renderTask.getErrors( );
assertEquals( 0, errors.size( ) );
}
finally
{
renderTask.close( );
}
return new String( buffer.toString( "UTF-8" ) );
}
示例3: run
import org.eclipse.birt.report.engine.api.HTMLRenderOption; //导入方法依赖的package包/类
public void run( ) throws Exception
{
// render the generated report document
IReportDocument doc = engine.openReportDocument( fileName );
long pageCount = doc.getPageCount( );
for ( int i = 1; i <= pageCount; i++ )
{
IRenderTask renderTask = engine.createRenderTask( doc );
HTMLRenderOption option = new HTMLRenderOption( );
option.setOutputFormat( "html" );
option.setOutputStream( new ByteArrayOutputStream( ) );
renderTask.setRenderOption( option );
renderTask.setPageNumber( i );
renderTask.render( );
List errors = renderTask.getErrors( );
assertEquals( 0, errors.size( ) );
renderTask.close( );
}
doc.close( );
}
示例4: buildRenderOptions
import org.eclipse.birt.report.engine.api.HTMLRenderOption; //导入方法依赖的package包/类
@Override
protected RenderOption buildRenderOptions(HttpServletRequest request, HttpServletResponse response) throws IOException {
HTMLRenderOption opt = new HTMLRenderOption();
opt.setEmitterID("io.github.kewne.spring_birt.htmlPlusEmbeddedSvg");
opt.setOutputFormat(HTMLRenderOption.HTML);
opt.setOutputStream(response.getOutputStream());
opt.setBaseImageURL(null);
opt.setImageDirectory(null);
opt.setEnableAgentStyleEngine(true);
return opt;
}
示例5: setUp
import org.eclipse.birt.report.engine.api.HTMLRenderOption; //导入方法依赖的package包/类
protected void setUp( ) throws Exception
{
super.setUp( );
removeResource( );
htmlOption = new HTMLRenderOption( );
htmlOption.setOutputFormat( HTMLRenderOption.HTML );
}
示例6: getPreferredRenderOption
import org.eclipse.birt.report.engine.api.HTMLRenderOption; //导入方法依赖的package包/类
public IRenderOption getPreferredRenderOption( )
{
HTMLRenderOption renderOption = new HTMLRenderOption( );
renderOption.setEmitterID( getID( ) );
renderOption.setOutputFormat( "html" ); //$NON-NLS-1$
// TODO set option values
return renderOption;
}
示例7: testRenderReport
import org.eclipse.birt.report.engine.api.HTMLRenderOption; //导入方法依赖的package包/类
/**
* Test if text with underline, line-through or overline, uri
* images(bmp,gif,jpg,png,tif),url images(gif), embeded
* images(bmp,gif,jpg,png,tif), and report design with page breaks can be
* correctly rendered. <br>
* <br>
* The result PS files have same names as the respective report design, and
* are put in folder named "testresult" under current working folder. For
* Eclipse, the current working folder is normally the folder where Eclipse
* is installed. <br>
* <b>To check the results, every result files should be checked manually.</b>
* @throws Exception
*/
public void testRenderReport( ) throws Exception
{
if ( isOnWindows( ) )
{
String thePackage = "org/eclipse/birt/report/engine/emitter/postscript/";
String[] designs = new String[]{"underline", "uriImages",
"urlImages", "pageBreak", "embededImages", "svgImages",
"pageBackgroundColor", "lableWithBorder",
"pageBackgroundImage", "gridBackgroundImage",
"pageBackgroundImageNoRepeat",
"pageBackgroundImageRepeatX", "pageBackgroundImageRepeatY"};
String suffix = ".rptdesign";
HTMLRenderOption options = new HTMLRenderOption( );
options.setOutputFormat( "postscript" );
String resultFolder = "testresult/";
for ( int i = 0; i < designs.length; i++ )
{
options.setOutputFileName( resultFolder + designs[i] + ".ps" );
String design = thePackage + designs[i] + suffix;
IRunAndRenderTask runAndRenderTask = createRunAndRenderTask( design );
runAndRenderTask.setRenderOption( options );
runAndRenderTask.run( );
runAndRenderTask.close( );
}
System.out.println( "please check result manually in folder : "
+ new File( resultFolder ).getAbsolutePath( ) );
}
}
示例8: render
import org.eclipse.birt.report.engine.api.HTMLRenderOption; //导入方法依赖的package包/类
/**
* Render a report design file and return the result.
*
* @param designFile
* @return render result.
* @throws EngineException
* @throws IOException
*/
protected String render( String designFile ) throws EngineException,
IOException
{
HTMLRenderOption options = new HTMLRenderOption( );
ByteArrayOutputStream out = new ByteArrayOutputStream( );
options.setOutputStream( out );
options.setOutputFormat( "html" );
render( designFile, options );
String result = new String( out.toByteArray( ) );
out.close( );
return result;
}
示例9: render
import org.eclipse.birt.report.engine.api.HTMLRenderOption; //导入方法依赖的package包/类
/**
* Render a report design file and return the result.
*
* @param designFile
* @return render result.
* @throws EngineException
* @throws IOException
*/
protected String render( String designFile ) throws EngineException,
IOException
{
HTMLRenderOption options = new HTMLRenderOption( );
ByteArrayOutputStream out = new ByteArrayOutputStream( );
options.setOutputStream( out );
options.setHtmlPagination( true );
options.setOutputFormat( "html" );
render( designFile, options );
String result = new String( out.toByteArray( ) );
out.close( );
return result;
}
示例10: getAllInstanceIds
import org.eclipse.birt.report.engine.api.HTMLRenderOption; //导入方法依赖的package包/类
private Set<InstanceID> getAllInstanceIds( IReportDocument document )
throws EngineException, UnsupportedEncodingException
{
Set<InstanceID> instanceIds = new HashSet<InstanceID>();
IRenderTask task = engine.createRenderTask( document );
ByteArrayOutputStream ostream = new ByteArrayOutputStream( );
// create the render options
HTMLRenderOption option = new HTMLRenderOption( );
option.setOutputFormat( "html" );
option.setOutputStream( ostream );
option.setEnableMetadata( true );
// set the render options
task.setRenderOption( option );
assertTrue(task.getRenderOption( ).equals( option ));
task.render( );
task.close( );
String content = ostream.toString( "utf-8" );
// get all the instance ids
Pattern iidPattern = Pattern.compile( "iid=\"([^\"]*)\"" );
Matcher matcher = iidPattern.matcher( content );
while ( matcher.find( ) )
{
String strIid = matcher.group( 1 );
InstanceID iid = InstanceID.parse( strIid );
instanceIds.add( iid );
}
return instanceIds;
}
示例11: getAllInstanceIds
import org.eclipse.birt.report.engine.api.HTMLRenderOption; //导入方法依赖的package包/类
private Set<InstanceID> getAllInstanceIds( IReportDocument document )
throws EngineException, UnsupportedEncodingException
{
Set<InstanceID> instanceIds = new HashSet<InstanceID>( );
IRenderTask task = engine.createRenderTask( document );
ByteArrayOutputStream ostream = new ByteArrayOutputStream( );
// create the render options
HTMLRenderOption option = new HTMLRenderOption( );
option.setOutputFormat( "html" );
option.setOutputStream( ostream );
option.setEnableMetadata( true );
// set the render options
task.setRenderOption( option );
assertTrue( task.getRenderOption( ).equals( option ) );
task.render( );
task.close( );
String content = ostream.toString( "utf-8" );
// get all the instance ids
Pattern iidPattern = Pattern.compile( "iid=\"([^\"]*)\"" );
Matcher matcher = iidPattern.matcher( content );
while ( matcher.find( ) )
{
String strIid = matcher.group( 1 );
InstanceID iid = InstanceID.parse( strIid );
instanceIds.add( iid );
}
return instanceIds;
}
示例12: renderHtmlReport
import org.eclipse.birt.report.engine.api.HTMLRenderOption; //导入方法依赖的package包/类
@Override
public void renderHtmlReport(String reportName,
Map<String, Object> parameters, OutputStream out, long pageNumber,
boolean overwrite) throws BirtReportException {
try {
String reportFileName = absolutePathOf(reportFileName(reportName));
String documentFileName = absoluteTempPath(
documentFileName(reportName));
recreateReportDocument(reportName, parameters, overwrite,
reportFileName, documentFileName);
IReportDocument reportDocument = reportEngine
.openReportDocument(documentFileName);
HTMLRenderOption htmlOptions = new HTMLRenderOption();
htmlOptions.setOutputFormat(IRenderOption.OUTPUT_FORMAT_HTML);
htmlOptions.setOutputStream(out);
htmlOptions.setImageHandler(new HTMLServerImageHandler());
htmlOptions.setEmbeddable(true);
htmlOptions.setBaseImageURL(baseImageURL);
htmlOptions.setImageDirectory(imageDirectory);
htmlOptions.setHtmlPagination(true);
htmlOptions.setMasterPageContent(false);
htmlOptions.setPageFooterFloatFlag(true);
IRenderTask renderTask = reportEngine
.createRenderTask(reportDocument,
reportDocument.getReportRunnable());
renderTask.setRenderOption(htmlOptions);
renderTask.setPageNumber(pageNumber);
injectLocale(renderTask);
renderTask.render();
renderTask.close();
} catch (EngineException | IOException e) {
throw new BirtReportException(e);
}
}
示例13: renderHtmlReport
import org.eclipse.birt.report.engine.api.HTMLRenderOption; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void renderHtmlReport(String outputFile, String reportName)
throws EngineException, FileNotFoundException {
String file = this.getClass().getResource(reportName).getPath();
IReportRunnable iReportRunnable = reportEngine.openReportDesign(file);
IGetParameterDefinitionTask parameterDefinitionTask = reportEngine
.createGetParameterDefinitionTask(iReportRunnable);
IRunAndRenderTask runAndRenderTask = reportEngine
.createRunAndRenderTask(iReportRunnable);
Collection<IParameterDefnBase> parameterDefns = parameterDefinitionTask
.getParameterDefns(true);
for (IParameterDefnBase parameterDefn : parameterDefns) {
System.out
.println("Displayname: " + parameterDefn.getDisplayName());
logger.info("Helptext: " + parameterDefn.getHelpText());
logger.info("Name: " + parameterDefn.getName());
logger.info("Typename: " + parameterDefn.getTypeName());
logger.info("ParameterType: "
+ BirtParameterType.valueOf(parameterDefn
.getParameterType()));
logger.info("PromptText: " + parameterDefn.getPromptText());
logger.info("DefaultValue: "
+ parameterDefinitionTask.getDefaultValue(parameterDefn));
logger.info("Required: " + parameterDefn.getHandle());
runAndRenderTask.setParameterValue(parameterDefn.getName(), 10101);
}
IRenderOption options = new RenderOption();
HTMLRenderOption htmlOptions = new HTMLRenderOption(options);
htmlOptions.setOutputFormat("html");
htmlOptions.setOutputStream(new FileOutputStream(outputFile));
htmlOptions.setImageHandler(new HTMLServerImageHandler());
htmlOptions.setBaseImageURL("images");
htmlOptions.setImageDirectory("target/images");
runAndRenderTask.setRenderOption(htmlOptions);
runAndRenderTask.run();
runAndRenderTask.close();
}
示例14: testCancelRunAndRenderTask
import org.eclipse.birt.report.engine.api.HTMLRenderOption; //导入方法依赖的package包/类
public void testCancelRunAndRenderTask( )
{
// this report sleeps for 2 seconds after creation,
// which allows separate test threads to cancel it
String input = this.genInputFile( "pages9.rptdesign" );
try
{
IReportRunnable runnable = engine
.openReportDesign( new FileInputStream( new File( input ) ) );
IRunAndRenderTask task = engine.createRunAndRenderTask( runnable );
HTMLRenderOption option = new HTMLRenderOption( );
option.setOutputFormat( "html" );
for ( int i = 0; i < 3; i++ )
{
task = engine.createRunAndRenderTask( runnable );
task.setRenderOption( option );
task.setAppContext( new HashMap( ) );
task.run( );
task.close( );
assertEquals(task.STATUS_SUCCEEDED, task.getStatus());
assertEquals(0, task.getErrors().size());
}
task = engine.createRunAndRenderTask( runnable );
task.setRenderOption( option );
task.setAppContext( new HashMap( ) );
engine.getConfig( ).getAppContext( ).put( "taskToCancel", task );
engine.getConfig( ).getAppContext( ).put( "taskToCancelWithSignal", null );
CancelTask cancelThread = new CancelTask( "cancelThread", task );
cancelThread.start( );
task.run( );
assertEquals(task.STATUS_CANCELLED, task.getStatus());
assertEquals(0, task.getErrors().size());
task.close( );
task = engine.createRunAndRenderTask( runnable );
engine.getConfig( ).getAppContext( ).put( "taskToCancel", null );
engine.getConfig( ).getAppContext( ).put( "taskToCancelWithSignal", task );
task.setRenderOption( option );
CancelWithFlagTask cancelWithFlagTask = new CancelWithFlagTask( "cancelWithFlagTask", task );
cancelWithFlagTask.start( );
task.run( );
assertEquals(task.STATUS_CANCELLED, task.getStatus());
assertEquals(1, task.getErrors().size());
assertEquals(((EngineException)task.getErrors().get(0)).getMessage(), cancelMessage);
task.close( );
task = engine.createRunAndRenderTask( runnable );
engine.getConfig( ).getAppContext( ).put( "taskToCancel", null );
engine.getConfig( ).getAppContext( ).put( "taskToCancelWithSignal", null );
task.setRenderOption( option );
task.run( );
assertEquals(task.STATUS_SUCCEEDED, task.getStatus());
assertEquals(0, task.getErrors().size());
task.close( );
}
catch ( Exception e )
{
e.printStackTrace( );
fail( "RunAndRenderTask.cancel() failed!" );
}
}
示例15: renderDocument
import org.eclipse.birt.report.engine.api.HTMLRenderOption; //导入方法依赖的package包/类
public String renderDocument( String reportDocument )
throws EngineException, IOException
{
ByteArrayOutputStream out = new ByteArrayOutputStream( );
IArchiveFile af = archiveFactory.openArchive( reportDocument, "r" );
try
{
IReportDocument document = engine.openReportDocument( af
.getSystemId( ), new ArchiveReader( af ), new HashMap( ) );
try
{
IRenderTask render = engine.createRenderTask( document );
try
{
HTMLRenderOption option = new HTMLRenderOption( );
option.setOutputFormat( IRenderOption.OUTPUT_FORMAT_HTML );
option.setOutputStream( out );
render.setRenderOption( option );
render.render( );
if ( !render.getErrors( ).isEmpty( ) )
{
for ( Object e : render.getErrors( ) )
{
( (Exception) e ).printStackTrace( );
}
fail( "render error" );
}
try
{
return out.toString( "utf-8" );
}
catch ( UnsupportedEncodingException ue )
{
return out.toString( );
}
}
finally
{
render.close( );
}
}
finally
{
document.close( );
}
}
finally
{
af.close( );
}
}