Trying to "append" multiple rptdesigns to single output (HTML, BIRT 2.2) [message #254015] |
Thu, 30 August 2007 19:30 |
Eclipse User |
|
|
|
Originally posted by: chesser_z.yahoo.com
Does anyone know how to append multiple rptdesigns into the same output? I
am using HTML output currently.
The examples I see for "Compound reports" seem like just one rptdesign with
multiple data sources. Also called "sub-reporting".
The main reason is that I have a cross tab and two charts that will be
called with different data about 10 times. These should all be in the same
file as a "report" so the user can view it. I don't want to have one large
rptdesign where I copy and paste everything and possibly have problems with
the overall width of the items.
If this is possible, do you know if I can set a layout of how it appends?
i.e. append 3 reports per row, then line break?
My workaround currently would be to merge the reports with my own code
afterwards via parsing.
Thanks,
John
|
|
|
Re: Trying to "append" multiple rptdesigns to single output (HTML, BIRT 2.2) [message #254023 is a reply to message #254015] |
Thu, 30 August 2007 20:46 |
Eclipse User |
|
|
|
Originally posted by: chesser_z.yahoo.com
I found one way that I think will work,
((HTMLRenderOption)renderOption).setEmbeddable(true);
along with setting the output stream to the same file.
Going to give it a try.
"John Chesser" <chesser_z@yahoo.com> wrote in message
news:fb75s3$56b$1@build.eclipse.org...
> Does anyone know how to append multiple rptdesigns into the same output?
> I
> am using HTML output currently.
>
> The examples I see for "Compound reports" seem like just one rptdesign
> with
> multiple data sources. Also called "sub-reporting".
>
> The main reason is that I have a cross tab and two charts that will be
> called with different data about 10 times. These should all be in the
> same
> file as a "report" so the user can view it. I don't want to have one
> large
> rptdesign where I copy and paste everything and possibly have problems
> with
> the overall width of the items.
>
> If this is possible, do you know if I can set a layout of how it appends?
> i.e. append 3 reports per row, then line break?
>
> My workaround currently would be to merge the reports with my own code
> afterwards via parsing.
>
> Thanks,
> John
>
>
|
|
|
Re: Trying to "append" multiple rptdesigns to single output (HTML, BIRT 2.2) [message #254027 is a reply to message #254023] |
Thu, 30 August 2007 22:30 |
Eclipse User |
|
|
|
Originally posted by: jasonweathersby.alltel.net
This is a multi-part message in MIME format.
--------------090905030107070201090605
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
John,
Here are two examples:
one to combine html
another to combine pdf
Jason
John Chesser wrote:
> I found one way that I think will work,
>
> ((HTMLRenderOption)renderOption).setEmbeddable(true);
>
> along with setting the output stream to the same file.
>
> Going to give it a try.
>
>
> "John Chesser" <chesser_z@yahoo.com> wrote in message
> news:fb75s3$56b$1@build.eclipse.org...
>> Does anyone know how to append multiple rptdesigns into the same output?
>> I
>> am using HTML output currently.
>>
>> The examples I see for "Compound reports" seem like just one rptdesign
>> with
>> multiple data sources. Also called "sub-reporting".
>>
>> The main reason is that I have a cross tab and two charts that will be
>> called with different data about 10 times. These should all be in the
>> same
>> file as a "report" so the user can view it. I don't want to have one
>> large
>> rptdesign where I copy and paste everything and possibly have problems
>> with
>> the overall width of the items.
>>
>> If this is possible, do you know if I can set a layout of how it appends?
>> i.e. append 3 reports per row, then line break?
>>
>> My workaround currently would be to merge the reports with my own code
>> afterwards via parsing.
>>
>> Thanks,
>> John
>>
>>
>
>
--------------090905030107070201090605
Content-Type: java/*;
name="CombineReportsPDF.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="CombineReportsPDF.java"
package REAPI;
import java.util.logging.Level;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.EngineException;
import org.eclipse.birt.report.engine.api.PDFRenderOption;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
import java.io.FileOutputStream;
import java.io.ByteArrayOutputStream;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfCopyFields;
public class CombineReportsPDF {
public void concat(byte[] ba1, byte[] ba2, String outpath){
try{
PdfReader rd1 = new PdfReader( ba1 );
PdfReader rd2 = new PdfReader( ba2 );
PdfCopyFields cpy = new PdfCopyFields( new FileOutputStream( outpath ));
cpy.addDocument(rd1);
cpy.addDocument(rd2);
cpy.close();
}catch(Exception e){
e.printStackTrace();
}
}
public void runReport() throws EngineException
{
IReportEngine engine=null;
EngineConfig config = null;
try{
config = new EngineConfig( );
config.setBIRTHome(" C:\\birt\\birt-runtime-2_2_0\\birt-runtime-2_2_0\\ReportEngi ne ");
config.setLogConfig(null, Level.OFF);
Platform.startup( config );
IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
engine = factory.createReportEngine( config );
}catch( Exception ex){
ex.printStackTrace();
}
IReportRunnable design, design2 = null;
//Open the report design
design = engine.openReportDesign("Reports/TopNPercent.rptdesign");
design2 = engine.openReportDesign("Reports/TopSellingProducts.rptdesign ");
//Create task to run and render the report,
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
task.setParameterValue("Top Percentage", (new Integer(3)));
task.setParameterValue("Top Count", (new Integer(5)));
task.validateParameters();
PDFRenderOption options = new PDFRenderOption();
ByteArrayOutputStream fso= new ByteArrayOutputStream();
ByteArrayOutputStream fso2= new ByteArrayOutputStream();
options.setOutputStream(fso);
options.setOutputFormat("pdf");
task.setRenderOption(options);
task.run();
task.close();
//Create task to run and render the report,
task = engine.createRunAndRenderTask(design2);
options.setOutputStream(fso2);
options.setOutputFormat("pdf");
task.setRenderOption(options);
task.run();
task.close();
concat( fso.toByteArray(), fso2.toByteArray(), "output/resample/Combined.pdf");
engine.destroy();
Platform.shutdown();
System.out.println("Finished");
}
/**
* @param args
*/
public static void main(String[] args) {
try
{
CombineReportsPDF ex = new CombineReportsPDF( );
ex.runReport();
}
catch ( Exception e )
{
e.printStackTrace();
}
}
}
--------------090905030107070201090605
Content-Type: java/*;
name="CombineReports.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="CombineReports.java"
package REAPI;
import java.util.HashMap;
import java.util.logging.Level;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.EngineConstants;
import org.eclipse.birt.report.engine.api.EngineException;
import org.eclipse.birt.report.engine.api.HTMLActionHandler;
import org.eclipse.birt.report.engine.api.HTMLRenderOption;
import org.eclipse.birt.report.engine.api.HTMLServerImageHandler;
import org.eclipse.birt.report.engine.api.HTMLCompleteImageHandler;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
import org.eclipse.birt.report.engine.api.RenderOption;
import java.io.FileOutputStream;
import java.io.File;
public class CombineReports {
public void runReport() throws EngineException
{
IReportEngine engine=null;
EngineConfig config = null;
try{
config = new EngineConfig( );
config.setBIRTHome(" C:\\birt\\birt-runtime-2_2_0\\birt-runtime-2_2_0\\ReportEngi ne ");
config.setLogConfig(null, Level.OFF);
Platform.startup( config );
IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
engine = factory.createReportEngine( config );
}catch( Exception ex){
ex.printStackTrace();
}
IReportRunnable design, design2 = null;
//Open the report design
design = engine.openReportDesign("Reports/TopNPercent.rptdesign");
design2 = engine.openReportDesign("Reports/TopSellingProducts.rptdesign ");
//Create task to run and render the report,
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
task.setParameterValue("Top Percentage", (new Integer(3)));
task.setParameterValue("Top Count", (new Integer(5)));
task.validateParameters();
HTMLRenderOption options = new HTMLRenderOption();
FileOutputStream fso=null, fso2=null;
try{
fso = new FileOutputStream(new File("output/resample/Combined.html"), true);
}catch (Exception e){
e.printStackTrace();
}
options.setOutputStream(fso);
options.setEmbeddable(true);
options.setOutputFormat("html");
options.setImageDirectory("images");
//ImageHandlerTest
//options.setImageHandler(new MyImageHandler());
//options.setImageHandler(new HTMLServerImageHandler());
options.setImageHandler(new HTMLCompleteImageHandler());
task.setRenderOption(options);
task.run();
//Create task to run and render the report,
task = engine.createRunAndRenderTask(design2);
try{
fso.flush();
fso.close();
fso2 = new FileOutputStream(new File("output/resample/Combined.html"), true);
}catch (Exception e){
e.printStackTrace();
}
options.setOutputStream(fso2);
task.setRenderOption(options);
task.run();
task.close();
try{
fso2.flush();
fso2.close();
}catch(Exception e){
e.printStackTrace();
}
engine.destroy();
Platform.shutdown();
System.out.println("Finished");
}
/**
* @param args
*/
public static void main(String[] args) {
try
{
CombineReports ex = new CombineReports( );
ex.runReport();
}
catch ( Exception e )
{
e.printStackTrace();
}
}
private class CancelReport extends Thread
{
private IRunAndRenderTask rTask;
public CancelReport( String threadName, IRunAndRenderTask task){
super(threadName);
rTask = task;
}
public void run()
{
try{
Thread.currentThread().sleep( 100 );
rTask.cancel();
System.out.println("######Report Cancelled#######");
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
}
--------------090905030107070201090605--
|
|
|
Powered by
FUDForum. Page generated in 0.03257 seconds