Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » How to create a PDF report using designer?
How to create a PDF report using designer? [message #118490] Fri, 27 January 2006 10:16 Go to next message
Eclipse UserFriend
Originally posted by: karthi_mit.rediffmail.com

Hi,

I wanted to produce a PDF report using BIRT Report designer.

Can u plz help me?
Re: How to create a PDF report using designer? [message #118947 is a reply to message #118490] Fri, 27 January 2006 17:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mlorenz.nc.rr.com

Here's an example:

protected String format =PDF_FORMAT; //default PDF
public static final String PDF_FORMAT =
HTMLRenderOption.OUTPUT_FORMAT_PDF;
public static final String HTML_FORMAT =
HTMLRenderOption.OUTPUT_FORMAT_HTML;
protected static EngineConfig config;
public static ReportEngine ENGINE; //only create ONE engine for ALL
reports
/**
* Set up for BIRT report generation. Subclasses will
* do the actual generation based on their own designs,
* but using the one and only engine I create.
*/
static { //static initializer block
config = new EngineConfig( );
config.setEngineHome( "C:\\BIRT\\birt-runtime-2_0_0\\Report Engine"
); //TODO Set CORRECT home!!
//only create ONE engine for ALL reports
ENGINE = new ReportEngine( config );
// Create the emitter configuration.
HTMLEmitterConfig hc = new HTMLEmitterConfig( );
// Use the "HTML complete" image handler to write the files to disk.
HTMLCompleteImageHandler imageHandler = new HTMLCompleteImageHandler( );
hc.setImageHandler( imageHandler );
// Associate the configuration with the HTML output format.
config.setEmitterConfiguration( HTML_FORMAT, hc );
}

/**
* Create a formatted output file using a BIRT .rptdesign XML file.
*/
public void generate() {
//------ Run reports
//--> IF params are needed for the report,
// add logic at
http://eclipse.org/birt/index.php?page=deploy/engine.html

// Output can be HTML or PDF. PDF is default.
IReportRunnable report = null;
try {
report = ENGINE.openReportDesign( getDesignFilepath() );
} catch (EngineException e) {
e.printStackTrace();
return;
}
// 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\\"; //TODO change to deployment location
outputPath = outputPath + getOutputFilename();
options.setOutputFileName(outputPath);
task.setRenderOption( options );
// Set parameter values using a HashMap. Parameters are name/value pairs.
// The values must be Java objects of the correct type.
HashMap params = getParameters(); //each report has its own params
task.setParameterValues( params );
task.validateParameters();

// Run the report.
try {
task.run( );
} catch (EngineException e) {
e.printStackTrace();
}
Re: How to create a PDF report using designer? [message #119730 is a reply to message #118947] Mon, 30 January 2006 13:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: karthi_mit.rediffmail.com

Thanks Mark
Re: How to create a PDF report using designer? [message #120290 is a reply to message #118947] Mon, 30 January 2006 20:37 Go to previous message
Eclipse UserFriend
Originally posted by: elhanan.migdal-group.co.il

mark, when i tried converting to pdf from the viewer, i got my hebrew
strings reversed (even though on the report itself they were fine), anyway
i change it ?
Previous Topic:Problem with renderContext.setImageDirectory(IMAGE_URL)
Next Topic:No space in hidden elements
Goto Forum:
  


Current Time: Sat Nov 09 00:07:10 GMT 2024

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

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

Back to the top