Skip to main content



      Home
Home » Archived » BIRT » Integrated ReportEngine generates blank PDF
Integrated ReportEngine generates blank PDF [message #263724] Tue, 25 December 2007 14:45 Go to next message
Eclipse UserFriend
Originally posted by: darian.criticode.com

Hello all,

I've encountered a strange problem where I'm able to view a particular
report from inside the BIRT Designer as a PDF and all appears as it
should. However, the very same report when run using the ReportEngine
API generates a blank PDF -- absolutely no text, tables, or graphs are
displayed. What's most strange is the fact that the PDF outline is
still available when the generated file is viewed using Adobe Acrobat.

I first tried changing the font path, but ruled that out since the table
borders in the report are not being displayed at all either, which
indicates that their must be some other problem. I'm currently at a
loss as to what the root cause may be.

Has anyone encountered anything like this before?

Thanks in advance for any insight,

Darian
--
Darian Anthony Patrick, GWAS, GSSP-Java, ZCE
Principal, Application Development
Criticode LLC
Web: http://criticode.com
Re: Integrated ReportEngine generates blank PDF [message #263728 is a reply to message #263724] Tue, 25 December 2007 19:31 Go to previous messageGo to next message
Eclipse UserFriend
Hi Darian

I have tried as your description in Designer and using EngineAPI, can not
reproduce your issue. So would you like to tell me which build you used, how
your report designed and how you called EngineAPI?

Thanks

"Darian Anthony Patrick" <darian@criticode.com> wrote in message
news:fkrmki$a7l$1@build.eclipse.org...
> Hello all,
>
> I've encountered a strange problem where I'm able to view a particular
> report from inside the BIRT Designer as a PDF and all appears as it
> should. However, the very same report when run using the ReportEngine
> API generates a blank PDF -- absolutely no text, tables, or graphs are
> displayed. What's most strange is the fact that the PDF outline is
> still available when the generated file is viewed using Adobe Acrobat.
>
> I first tried changing the font path, but ruled that out since the table
> borders in the report are not being displayed at all either, which
> indicates that their must be some other problem. I'm currently at a
> loss as to what the root cause may be.
>
> Has anyone encountered anything like this before?
>
> Thanks in advance for any insight,
>
> Darian
> --
> Darian Anthony Patrick, GWAS, GSSP-Java, ZCE
> Principal, Application Development
> Criticode LLC
> Web: http://criticode.com
Re: Integrated ReportEngine generates blank PDF [message #263737 is a reply to message #263728] Wed, 26 December 2007 12:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: darian.criticode.com

Hi Tianli,

The report is extremely simple, and contains only one data source which
supplies data layed out in a table. Some statistical calculations are
done to determine weighted averages, but nothing that should cause
problems for BIRT, especially since it perfectly renders to HTML in the
Designer and EngineAPI, and renders to PDF fine in the Designer.

I've created a class called ExecuteReport based on the ReportEngine API
tutorial to invoke the RunAndRender task. The class method buildReport
is being called from PHP using the PHP-Java Bridge. Output is returned
from the method back to PHP using a toString() call on the
ByteArrayOutputStream response object.

Following is the content of the ExecuteReport class. Please take a look
and let me know if you spot any errors. Thanks alot for your help.

package com.example.report;

import java.io.ByteArrayOutputStream;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;

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.HTMLActionHandler;
import org.eclipse.birt.report.engine.api.HTMLRenderOption;
import org.eclipse.birt.report.engine.api.HTMLServerImageHandler;
import org.eclipse.birt.report.engine.api.IPDFRenderOption;
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.PDFRenderOption;

public class ExecuteReport {

protected static Logger logger = Logger.getLogger(
ExecuteReport.class.getName( ) );

public static String buildReport( String reportFileName, String
renderFormat, HashMap<String, Object> reportParameters ) throws
EngineException {

IReportEngine engine = null;
EngineConfig config = null;
try
{
// Configure the Engine and start the Platform
config = new EngineConfig();
config.setEngineHome(
System.getProperty("example.birt.engine.base.dir") );
config.setLogConfig(
System.getProperty("example.birt.log.path"),
Level.FINE
// Level.ALL
);

Platform.startup(config);
IReportEngineFactory factory = (IReportEngineFactory) Platform

..createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ ENGINE_FACTORY);
engine = factory.createReportEngine(config);
engine.changeLogLevel(Level.INFO); // was WARNING
}
catch (Exception ex)
{
logger.log( Level.SEVERE, ex.getMessage( ), ex );
}

IReportRunnable design = null;

// Open the report design
design = engine.openReportDesign(
System.getProperty("example.birt.report.base.dir") + reportFileName
);

// Create task to run and render the report,
IRunAndRenderTask task = engine.createRunAndRenderTask(design);

ByteArrayOutputStream response = new ByteArrayOutputStream();

if ( renderFormat.equals("pdf") )
{
PDFRenderOption options = new PDFRenderOption();
// options.setFontDirectory("/usr/share/fonts/truetype");
options.setEmbededFont(true);
options.setBaseURL( System.getProperty("example.birt.report.base.url") );
options.setSupportedImageFormats("JPG;PNG;BMP;SVG");
options.setOutputStream(response);
options.setOutputFormat("pdf");
task.setRenderOption(options);
}
else
{
HTMLRenderOption options = new HTMLRenderOption();
options.setActionHandler( new HTMLActionHandler() );
options.setImageHandler( new HTMLServerImageHandler() );
options.setBaseURL( System.getProperty("example.birt.report.base.url") );
// Tell the Engine to prepend all images with this URL - Note this
// requires using the HTMLServerImageHandler
options.setBaseImageURL(
System.getProperty("example.birt.report.base.imageUrl") );
options.setImageDirectory(
System.getProperty("example.birt.report.image.dir") );
// Tell the Engine what image formats are supported. Note you must have
// SVG in the string
// to render charts in SVG.
options.setSupportedImageFormats("JPG;PNG;BMP;SVG");
// Remove HTML and Body tags
options.setEmbeddable(true);
options.setOutputStream(response);
options.setOutputFormat("html");
task.setRenderOption(options);
}
task.setParameterValues(reportParameters);

// run the report and destroy the engine
// Note - If the program stays resident do not shutdown the Platform or
// the Engine
task.run();
task.close();
/*
* Platform.shutdown(); // should not be called here; see
* http://dev.eclipse.org/newslists/news.eclipse.birt/msg19456. html
* http://dev.eclipse.org/newslists/news.eclipse.birt/msg19458. html
* http://dev.eclipse.org/newslists/news.eclipse.birt/msg18100. html
*/
return response.toString();
}

}


Tianli wrote:
> Hi Darian
>
> I have tried as your description in Designer and using EngineAPI, can not
> reproduce your issue. So would you like to tell me which build you used, how
> your report designed and how you called EngineAPI?
>
> Thanks
>
> "Darian Anthony Patrick" <darian@criticode.com> wrote in message
> news:fkrmki$a7l$1@build.eclipse.org...
>> Hello all,
>>
>> I've encountered a strange problem where I'm able to view a particular
>> report from inside the BIRT Designer as a PDF and all appears as it
>> should. However, the very same report when run using the ReportEngine
>> API generates a blank PDF -- absolutely no text, tables, or graphs are
>> displayed. What's most strange is the fact that the PDF outline is
>> still available when the generated file is viewed using Adobe Acrobat.
>>
>> I first tried changing the font path, but ruled that out since the table
>> borders in the report are not being displayed at all either, which
>> indicates that their must be some other problem. I'm currently at a
>> loss as to what the root cause may be.
>>
>> Has anyone encountered anything like this before?
>>
>> Thanks in advance for any insight,
>>
>> Darian
>> --
>> Darian Anthony Patrick, GWAS, GSSP-Java, ZCE
>> Principal, Application Development
>> Criticode LLC
>> Web: http://criticode.com
>
>

--
Darian Anthony Patrick, GWAS, GSSP-Java, ZCE
Principal, Application Development
Criticode LLC
(215) 240-6566 Office
(866) 789-2992 Facsimile
Web: http://criticode.com
Email: darian@criticode.com
JID: darian@jabber.criticode.net
Re: Integrated ReportEngine generates blank PDF [message #263740 is a reply to message #263737] Wed, 26 December 2007 20:48 Go to previous messageGo to next message
Eclipse UserFriend
Hi Darian,

Thanks for your detail information, I check your code and run it in my
environment, I can get the correct ByteArrayOutputStream and also write the
stream into a pdf file. The result is correct. So I wonder what outputstream
have you got? Can you try to setOutputFile for double check?

"Darian Anthony Patrick" <darian@criticode.com> wrote in message
news:fku4be$dn6$1@build.eclipse.org...
> Hi Tianli,
>
> The report is extremely simple, and contains only one data source which
> supplies data layed out in a table. Some statistical calculations are
> done to determine weighted averages, but nothing that should cause
> problems for BIRT, especially since it perfectly renders to HTML in the
> Designer and EngineAPI, and renders to PDF fine in the Designer.
>
> I've created a class called ExecuteReport based on the ReportEngine API
> tutorial to invoke the RunAndRender task. The class method buildReport
> is being called from PHP using the PHP-Java Bridge. Output is returned
> from the method back to PHP using a toString() call on the
> ByteArrayOutputStream response object.
>
> Following is the content of the ExecuteReport class. Please take a look
> and let me know if you spot any errors. Thanks alot for your help.
>
> package com.example.report;
>
> import java.io.ByteArrayOutputStream;
> import java.util.HashMap;
> import java.util.logging.Level;
> import java.util.logging.Logger;
>
> 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.HTMLActionHandler;
> import org.eclipse.birt.report.engine.api.HTMLRenderOption;
> import org.eclipse.birt.report.engine.api.HTMLServerImageHandler;
> import org.eclipse.birt.report.engine.api.IPDFRenderOption;
> 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.PDFRenderOption;
>
> public class ExecuteReport {
>
> protected static Logger logger = Logger.getLogger(
> ExecuteReport.class.getName( ) );
>
> public static String buildReport( String reportFileName, String
> renderFormat, HashMap<String, Object> reportParameters ) throws
> EngineException {
>
> IReportEngine engine = null;
> EngineConfig config = null;
> try
> {
> // Configure the Engine and start the Platform
> config = new EngineConfig();
> config.setEngineHome(
> System.getProperty("example.birt.engine.base.dir") );
> config.setLogConfig(
> System.getProperty("example.birt.log.path"),
> Level.FINE
> // Level.ALL
> );
>
> Platform.startup(config);
> IReportEngineFactory factory = (IReportEngineFactory) Platform
>
> .createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_E NGINE_FACTORY);
> engine = factory.createReportEngine(config);
> engine.changeLogLevel(Level.INFO); // was WARNING
> }
> catch (Exception ex)
> {
> logger.log( Level.SEVERE, ex.getMessage( ), ex );
> }
>
> IReportRunnable design = null;
>
> // Open the report design
> design = engine.openReportDesign(
> System.getProperty("example.birt.report.base.dir") + reportFileName
> );
>
> // Create task to run and render the report,
> IRunAndRenderTask task = engine.createRunAndRenderTask(design);
>
> ByteArrayOutputStream response = new ByteArrayOutputStream();
>
> if ( renderFormat.equals("pdf") )
> {
> PDFRenderOption options = new PDFRenderOption();
> // options.setFontDirectory("/usr/share/fonts/truetype");
> options.setEmbededFont(true);
> options.setBaseURL( System.getProperty("example.birt.report.base.url") );
> options.setSupportedImageFormats("JPG;PNG;BMP;SVG");
> options.setOutputStream(response);
> options.setOutputFormat("pdf");
> task.setRenderOption(options);
> }
> else
> {
> HTMLRenderOption options = new HTMLRenderOption();
> options.setActionHandler( new HTMLActionHandler() );
> options.setImageHandler( new HTMLServerImageHandler() );
> options.setBaseURL( System.getProperty("example.birt.report.base.url") );
> // Tell the Engine to prepend all images with this URL - Note this
> // requires using the HTMLServerImageHandler
> options.setBaseImageURL(
> System.getProperty("example.birt.report.base.imageUrl") );
> options.setImageDirectory(
> System.getProperty("example.birt.report.image.dir") );
> // Tell the Engine what image formats are supported. Note you must have
> // SVG in the string
> // to render charts in SVG.
> options.setSupportedImageFormats("JPG;PNG;BMP;SVG");
> // Remove HTML and Body tags
> options.setEmbeddable(true);
> options.setOutputStream(response);
> options.setOutputFormat("html");
> task.setRenderOption(options);
> }
> task.setParameterValues(reportParameters);
>
> // run the report and destroy the engine
> // Note - If the program stays resident do not shutdown the Platform or
> // the Engine
> task.run();
> task.close();
> /*
> * Platform.shutdown(); // should not be called here; see
> * http://dev.eclipse.org/newslists/news.eclipse.birt/msg19456. html
> * http://dev.eclipse.org/newslists/news.eclipse.birt/msg19458. html
> * http://dev.eclipse.org/newslists/news.eclipse.birt/msg18100. html
> */
> return response.toString();
> }
>
> }
>
>
> Tianli wrote:
>> Hi Darian
>>
>> I have tried as your description in Designer and using EngineAPI, can not
>> reproduce your issue. So would you like to tell me which build you used,
>> how
>> your report designed and how you called EngineAPI?
>>
>> Thanks
>>
>> "Darian Anthony Patrick" <darian@criticode.com> wrote in message
>> news:fkrmki$a7l$1@build.eclipse.org...
>>> Hello all,
>>>
>>> I've encountered a strange problem where I'm able to view a particular
>>> report from inside the BIRT Designer as a PDF and all appears as it
>>> should. However, the very same report when run using the ReportEngine
>>> API generates a blank PDF -- absolutely no text, tables, or graphs are
>>> displayed. What's most strange is the fact that the PDF outline is
>>> still available when the generated file is viewed using Adobe Acrobat.
>>>
>>> I first tried changing the font path, but ruled that out since the table
>>> borders in the report are not being displayed at all either, which
>>> indicates that their must be some other problem. I'm currently at a
>>> loss as to what the root cause may be.
>>>
>>> Has anyone encountered anything like this before?
>>>
>>> Thanks in advance for any insight,
>>>
>>> Darian
>>> --
>>> Darian Anthony Patrick, GWAS, GSSP-Java, ZCE
>>> Principal, Application Development
>>> Criticode LLC
>>> Web: http://criticode.com
>>
>>
>
> --
> Darian Anthony Patrick, GWAS, GSSP-Java, ZCE
> Principal, Application Development
> Criticode LLC
> (215) 240-6566 Office
> (866) 789-2992 Facsimile
> Web: http://criticode.com
> Email: darian@criticode.com
> JID: darian@jabber.criticode.net
Re: Integrated ReportEngine generates blank PDF [message #263793 is a reply to message #263740] Sat, 29 December 2007 13:10 Go to previous message
Eclipse UserFriend
Originally posted by: darian.criticode.com

Hi Tianli,

I figured it out. The PDF was blank because I was returning
response.toString() rather than response.toByteArray().

Thanks for your help,

Darian

Tianli wrote:
> Hi Darian,
>
> Thanks for your detail information, I check your code and run it in my
> environment, I can get the correct ByteArrayOutputStream and also write the
> stream into a pdf file. The result is correct. So I wonder what outputstream
> have you got? Can you try to setOutputFile for double check?
>
> "Darian Anthony Patrick" <darian@criticode.com> wrote in message
> news:fku4be$dn6$1@build.eclipse.org...
>> Hi Tianli,
>>
>> The report is extremely simple, and contains only one data source which
>> supplies data layed out in a table. Some statistical calculations are
>> done to determine weighted averages, but nothing that should cause
>> problems for BIRT, especially since it perfectly renders to HTML in the
>> Designer and EngineAPI, and renders to PDF fine in the Designer.
>>
>> I've created a class called ExecuteReport based on the ReportEngine API
>> tutorial to invoke the RunAndRender task. The class method buildReport
>> is being called from PHP using the PHP-Java Bridge. Output is returned
>> from the method back to PHP using a toString() call on the
>> ByteArrayOutputStream response object.
>>
>> Following is the content of the ExecuteReport class. Please take a look
>> and let me know if you spot any errors. Thanks alot for your help.
>>
>> package com.example.report;
>>
>> import java.io.ByteArrayOutputStream;
>> import java.util.HashMap;
>> import java.util.logging.Level;
>> import java.util.logging.Logger;
>>
>> 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.HTMLActionHandler;
>> import org.eclipse.birt.report.engine.api.HTMLRenderOption;
>> import org.eclipse.birt.report.engine.api.HTMLServerImageHandler;
>> import org.eclipse.birt.report.engine.api.IPDFRenderOption;
>> 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.PDFRenderOption;
>>
>> public class ExecuteReport {
>>
>> protected static Logger logger = Logger.getLogger(
>> ExecuteReport.class.getName( ) );
>>
>> public static String buildReport( String reportFileName, String
>> renderFormat, HashMap<String, Object> reportParameters ) throws
>> EngineException {
>>
>> IReportEngine engine = null;
>> EngineConfig config = null;
>> try
>> {
>> // Configure the Engine and start the Platform
>> config = new EngineConfig();
>> config.setEngineHome(
>> System.getProperty("example.birt.engine.base.dir") );
>> config.setLogConfig(
>> System.getProperty("example.birt.log.path"),
>> Level.FINE
>> // Level.ALL
>> );
>>
>> Platform.startup(config);
>> IReportEngineFactory factory = (IReportEngineFactory) Platform
>>
>> .createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_E NGINE_FACTORY);
>> engine = factory.createReportEngine(config);
>> engine.changeLogLevel(Level.INFO); // was WARNING
>> }
>> catch (Exception ex)
>> {
>> logger.log( Level.SEVERE, ex.getMessage( ), ex );
>> }
>>
>> IReportRunnable design = null;
>>
>> // Open the report design
>> design = engine.openReportDesign(
>> System.getProperty("example.birt.report.base.dir") + reportFileName
>> );
>>
>> // Create task to run and render the report,
>> IRunAndRenderTask task = engine.createRunAndRenderTask(design);
>>
>> ByteArrayOutputStream response = new ByteArrayOutputStream();
>>
>> if ( renderFormat.equals("pdf") )
>> {
>> PDFRenderOption options = new PDFRenderOption();
>> // options.setFontDirectory("/usr/share/fonts/truetype");
>> options.setEmbededFont(true);
>> options.setBaseURL( System.getProperty("example.birt.report.base.url") );
>> options.setSupportedImageFormats("JPG;PNG;BMP;SVG");
>> options.setOutputStream(response);
>> options.setOutputFormat("pdf");
>> task.setRenderOption(options);
>> }
>> else
>> {
>> HTMLRenderOption options = new HTMLRenderOption();
>> options.setActionHandler( new HTMLActionHandler() );
>> options.setImageHandler( new HTMLServerImageHandler() );
>> options.setBaseURL( System.getProperty("example.birt.report.base.url") );
>> // Tell the Engine to prepend all images with this URL - Note this
>> // requires using the HTMLServerImageHandler
>> options.setBaseImageURL(
>> System.getProperty("example.birt.report.base.imageUrl") );
>> options.setImageDirectory(
>> System.getProperty("example.birt.report.image.dir") );
>> // Tell the Engine what image formats are supported. Note you must have
>> // SVG in the string
>> // to render charts in SVG.
>> options.setSupportedImageFormats("JPG;PNG;BMP;SVG");
>> // Remove HTML and Body tags
>> options.setEmbeddable(true);
>> options.setOutputStream(response);
>> options.setOutputFormat("html");
>> task.setRenderOption(options);
>> }
>> task.setParameterValues(reportParameters);
>>
>> // run the report and destroy the engine
>> // Note - If the program stays resident do not shutdown the Platform or
>> // the Engine
>> task.run();
>> task.close();
>> /*
>> * Platform.shutdown(); // should not be called here; see
>> * http://dev.eclipse.org/newslists/news.eclipse.birt/msg19456. html
>> * http://dev.eclipse.org/newslists/news.eclipse.birt/msg19458. html
>> * http://dev.eclipse.org/newslists/news.eclipse.birt/msg18100. html
>> */
>> return response.toString();
>> }
>>
>> }
>>
>>
>> Tianli wrote:
>>> Hi Darian
>>>
>>> I have tried as your description in Designer and using EngineAPI, can not
>>> reproduce your issue. So would you like to tell me which build you used,
>>> how
>>> your report designed and how you called EngineAPI?
>>>
>>> Thanks
>>>
>>> "Darian Anthony Patrick" <darian@criticode.com> wrote in message
>>> news:fkrmki$a7l$1@build.eclipse.org...
>>>> Hello all,
>>>>
>>>> I've encountered a strange problem where I'm able to view a particular
>>>> report from inside the BIRT Designer as a PDF and all appears as it
>>>> should. However, the very same report when run using the ReportEngine
>>>> API generates a blank PDF -- absolutely no text, tables, or graphs are
>>>> displayed. What's most strange is the fact that the PDF outline is
>>>> still available when the generated file is viewed using Adobe Acrobat.
>>>>
>>>> I first tried changing the font path, but ruled that out since the table
>>>> borders in the report are not being displayed at all either, which
>>>> indicates that their must be some other problem. I'm currently at a
>>>> loss as to what the root cause may be.
>>>>
>>>> Has anyone encountered anything like this before?
>>>>
>>>> Thanks in advance for any insight,
>>>>
>>>> Darian
>>>> --
>>>> Darian Anthony Patrick, GWAS, GSSP-Java, ZCE
>>>> Principal, Application Development
>>>> Criticode LLC
>>>> Web: http://criticode.com
>>>
>> --
>> Darian Anthony Patrick, GWAS, GSSP-Java, ZCE
>> Principal, Application Development
>> Criticode LLC
>> (215) 240-6566 Office
>> (866) 789-2992 Facsimile
>> Web: http://criticode.com
>> Email: darian@criticode.com
>> JID: darian@jabber.criticode.net
>
>

--
Darian Anthony Patrick, GWAS, GSSP-Java, ZCE
Principal, Application Development
Criticode LLC
(215) 240-6566 Office
(866) 789-2992 Facsimile
Web: http://criticode.com
Email: darian@criticode.com
JID: darian@jabber.criticode.net
Previous Topic:Save Output file with date/ sequence no
Next Topic:[Newbie] RPC and integrated java API
Goto Forum:
  


Current Time: Thu Jul 24 15:43:17 EDT 2025

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

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

Back to the top