|
|
Re: problem in generating PDF reports from linux system [message #549527 is a reply to message #549357] |
Tue, 27 July 2010 06:24 |
sudhir Messages: 7 Registered: September 2009 |
Junior Member |
|
|
Not getting any error in console or in logs.
I am using following code.
/* Partie initialisation */
ReportEngine engine = null;
EngineConfig engineConfig = new EngineConfig();
engineConfig.setEngineHome(birtPath);
File logDir = new File(strLogDir);
if (!logDir.exists()) {
logDir.mkdir();
}
if (log) {
engineConfig.setLogConfig(strLogDir, Level.INFO);
} else {
engineConfig.setLogConfig(strLogDir, Level.OFF);
}
try {
engine = new ReportEngine(engineConfig);
// Dont remove this code.If birt engine path is valid but it does
// not contain
// Birt Engine then it will validate Report engine object.
engine.getRootScope();
} catch (Exception e) {
e.printStackTrace();
Main
.getLogger()
.log(
"Error: Reporting engine path does not contain valid Birt Engine.");
ReportingUIErrorWriter.process(ReportingUIErrorProcessor
.getString("ERR_CODE_025"), null);
systemExit(FAILURE);
}
IReportRunnable design = null;
RenderOptionBase option = new RenderOptionBase();
if ((format.toLowerCase() != "pdf") && (format.toLowerCase() != "html"))
format = "pdf"; // format par défaut
option.setOutputFormat(format.toLowerCase()); // Format du fichier de
// sortie
/* Fin initialisation */
/* Préparation de l'édition */
try {
design = engine.openReportDesign(templateLoc);
} catch (EngineException e) {
Main.getLogger().log(
"Warning : Fail to open report Design file : "
+ e.getMessage());
ReportingUIErrorWriter.process(ReportingUIErrorProcessor
.getString("ERR_CODE_026"), null);
systemExit(FAILURE);
} catch (Exception e) {
e.printStackTrace();
if (e instanceof NullPointerException) {
Main.getLogger().log(
"Error: Reporting engine path is not correct.");
// Destroy the engine object.
if (engine != null) {
engine.destroy();
engine = null;
}
ReportingUIErrorWriter.process(ReportingUIErrorProcessor
.getString("ERR_CODE_027"), null);
systemExit(FAILURE);
}
}
try {
/*
* Changement de source inspiré de
* http://jsourcery.com/api/sourceforge/openreports/2.1/org/efs/openreports/engine/BirtReportEngine.source.html
*/
ReportDesignHandle reportDH = (ReportDesignHandle) design
.getDesignHandle();
List birtDataSources = reportDH.getAllDataSources();
Iterator iterator = birtDataSources.iterator();
while (iterator.hasNext()) {
OdaDataSourceHandle dataSH = (OdaDataSourceHandle) iterator
.next();
try {
// Mantis 04034, 04037 : Update FILELIST property for the
// data source with name "Source".
if (dataSH.getProperty("name").equals("Source")) {
dataSH.setStringProperty("FILELIST", dataSource
.getAbsolutePath());
}
} catch (SemanticException e) {
Main.getLogger().log(
"Warning : SemanticException in path change"
+ e.getMessage());
systemExit(FAILURE);
}
}
//drop Grid rows containing information about Location Host and Location Components.
if(!isSummaryReport){
if(isDetailedLocInfoDisabled){
reportDH.getElementByID(1112).dropAndClear(); // delete and clear the location hostname attribute
reportDH.getElementByID(1116).dropAndClear(); // delete and clear the location components attribute
}
}
design.setDesignHandle(reportDH);
/* Fin changement source */
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
/* Fin de la préparation */
/* Création PDF */
option.setOutputFileName(outputFile + format); // Nom du fichier de
// sortie
task.setRenderOption(option); // Chargement du fichier
if (!isSummaryReport) {
if (isWithout_DescInConfigFile) {
task.setParameterValue("withoutDesc", new Boolean(isWithout_DescInConfigFile).toString());
}
if (isWithMessInConfigFile) {
task.setParameterValue("withMess", new Boolean(isWithMessInConfigFile).toString());
}
}else{
task.setParameterValue("totalDuration", XMLReportParsing.totalDurationString.substring(1, XMLReportParsing.totalDurationString.length()-2));
}
/* Fin création PDF */
try {
// On crée le fichier où l'on va écrire. S'il existe déjà, on
// écrit à la suite
task.run(); // Déclenchement de l'édition
// ferme le fichier qui log le run de BIRT
} catch (EngineException e) {
e.printStackTrace();
Main.getLogger().log(
"Error in Report Generation : " + e.getMessage());
ReportingUIErrorWriter.process(ReportingUIErrorProcessor
.getString("ERR_CODE_028"), null);
systemExit(FAILURE);
}
task = null;
} catch (Exception e) {
e.printStackTrace();
Main.getLogger().log(
"Error in Report Generation : " + e.getMessage());
ReportingUIErrorWriter.process(ReportingUIErrorProcessor
.getString("ERR_CODE_028"), null);
systemExit(FAILURE);
}
I was suspecting it an issue of fonts file etc. as i used Arial font family in my report design. So I tried copying arial.ttf from my windows machine to Linux machine but still no success.
|
|
|
Powered by
FUDForum. Page generated in 0.03442 seconds