Skip to main content



      Home
Home » Archived » BIRT » How to create a PDF emitter?
How to create a PDF emitter? [message #114095] Tue, 24 January 2006 07:56 Go to next message
Eclipse UserFriend
Originally posted by: jan.tanis.coas.com

Hi,

I'm creating my own report generator right now and it works on HTML.
However, when I say that it has to generate a PDF file it still
generates HTML. Does someone knows why that happens?

Thanks, Jan.

EngineConfig config = new EngineConfig();

config.setEngineHome(engineHome);
String format = HTMLRenderOption.OUTPUT_FORMAT_HTML;
if(this.format.equalsIgnoreCase("PDF")) {
format = HTMLRenderOption.OUTPUT_FORMAT_PDF;
System.out.println("PDF OUTPUT");
}
HTMLEmitterConfig hc = new HTMLEmitterConfig();
HTMLCompleteImageHandler imageHandler
= new HTMLCompleteImageHandler();
hc.setImageHandler(imageHandler);
config.setEmitterConfiguration(
format
, hc);

ReportEngine engine = new ReportEngine(config);

IReportRunnable report = null;
Re: How to create a PDF emitter? [message #114286 is a reply to message #114095] Tue, 24 January 2006 10:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mlorenz.nc.rr.com

This works for me:

// Create a separate task for EACH report
IRunAndRenderTask task = ENGINE.createRunAndRenderTask( report );
// Set up options.
HTMLRenderOption options = new HTMLRenderOption( );
// HTML (if specified) or PDF (default)
options.setOutputFormat( format );
String outputPath = "C:\\BIRT\\";
outputPath = outputPath + getOutputFilename();
options.setOutputFileName(outputPath);
task.setRenderOption( options );

HTH, Mark
Re: How to create a PDF emitter? [message #115077 is a reply to message #114286] Wed, 25 January 2006 01:19 Go to previous message
Eclipse UserFriend
Originally posted by: jan.tanis.coas.com

Well, as you can see in this sourcecode I do that.

public void run() {

EngineConfig config = new EngineConfig();

config.setEngineHome(engineHome);
String format = HTMLRenderOption.OUTPUT_FORMAT_HTML;
if(formatType.equalsIgnoreCase("PDF")) {
format = HTMLRenderOption.OUTPUT_FORMAT_PDF;
}
HTMLEmitterConfig hc = new HTMLEmitterConfig();
HTMLCompleteImageHandler imageHandler
= new HTMLCompleteImageHandler();
hc.setImageHandler(imageHandler);
config.setEmitterConfiguration(
format
, hc);

ReportEngine engine = new ReportEngine(config);

IReportRunnable report = null;
try {
report = engine.openReportDesign(input);
} catch (EngineException e) {
System.err.println("Report not found!\n");
engine.destroy();
return;
}

if (format != null) {

parseParams(engine, report, parameters);

IRunAndRenderTask task =
engine.createRunAndRenderTask(report);
HTMLRenderOption options = new HTMLRenderOption();
options.setOutputFormat(format);
System.out.println(format);
options.setOutputStream(output);
task.setRenderOption(options);
task.setParameterValues(parameters);

// Run the report.

try {
task.run();
} catch (EngineException e1) {
System.err.println("Report run failed.\n");
System.err.println(e1.toString());
}
}

engine.destroy();
}


The error I get on generating the report is:
java.lang.IllegalAccessError: tried to access method
org.eclipse.birt.report.engine.css.engine.BIRTCSSEngine.<init >()V from
class org.eclipse.birt.report.engine.layout.area.impl.AbstractArea
at
org.eclipse.birt.report.engine.layout.area.impl.AbstractArea . <init>(AbstractArea.java:93)
at
org.eclipse.birt.report.engine.layout.area.impl.ContainerAre a. <init>(ContainerArea.java:39)
at
org.eclipse.birt.report.engine.layout.area.impl.LogicContain erArea. <init>(LogicContainerArea.java:29)
at
org.eclipse.birt.report.engine.layout.area.impl.PageArea.<init >(PageArea.java:44)
at
org.eclipse.birt.report.engine.layout.area.impl.AreaFactory. createPageArea(AreaFactory.java:280)
at
org.eclipse.birt.report.engine.layout.impl.PageLayoutManager .initializePage(PageLayoutManager.java:60)
at
org.eclipse.birt.report.engine.layout.impl.PageLayoutManager . <init>(PageLayoutManager.java:42)
at
org.eclipse.birt.report.engine.layout.impl.ReportLayoutEngin e.start(ReportLayoutEngine.java:94)
at
org.eclipse.birt.report.engine.presentation.WrappedEmitter.s tart(WrappedEmitter.java:66)
at
org.eclipse.birt.report.engine.presentation.LocalizedEmitter .start(LocalizedEmitter.java:200)
at
org.eclipse.birt.report.engine.executor.ReportExecutor.execu te(ReportExecutor.java:113)
at
org.eclipse.birt.report.engine.executor.ReportExecutor.execu te(ReportExecutor.java:87)
at
org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run (RunAndRenderTask.java:175)
at com.coas.cbirt.ReportGenerator.run(ReportGenerator.java:91)
at com.coas.cbirt.ReportGenerator.main(ReportGenerator.java:251 )

Regards, Jan.

Mark Lorenz wrote:
> This works for me:
>
> // Create a separate task for EACH report
> IRunAndRenderTask task = ENGINE.createRunAndRenderTask( report );
> // Set up options.
> HTMLRenderOption options = new HTMLRenderOption( );
> // HTML (if specified) or PDF (default)
> options.setOutputFormat( format );
> String outputPath = "C:\\BIRT\\";
> outputPath = outputPath + getOutputFilename();
> options.setOutputFileName(outputPath);
> task.setRenderOption( options );
>
> HTH, Mark
>
Previous Topic:Problem to see preview In BIRT 2.0
Next Topic:Reg : How to display a message such as "No data found"
Goto Forum:
  


Current Time: Sun Jun 08 20:24:31 EDT 2025

Powered by FUDForum. Page generated in 0.02521 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top