Note that there are some explanatory texts on larger screens.

plurals
  1. POBIRT - PDF report creation from a Linux platfrom
    primarykey
    data
    text
    <p>I am trying to call BIRT API in linux environment.</p> <p>My source is an XML file and i create html, xml and pdf reports on that source XML.</p> <p>My html and xml reports generates properly, but PDF report is created with size '0' (no contents).</p> <p>However if i run the same program from a windows system, PDF report is created properly.</p> <p>Is BIRT having platform dependent API?</p> <p>I am using following code...</p> <pre><code>public static void generateReport(String format, String birtPath, String outputFile, String templateLoc, boolean log, File dataSource, boolean isSummaryReport) throws Exception { File outputFileObj = new File(outputFile + format); if (outputFileObj.exists()) { if (!outputFileObj.delete()) { Main .getLogger() .log( "Error: A File with the same name '" + outputFileObj.getName() + "' exists in the result folder and it can't be overwritten." + LINE_SEPARATOR + "If it is opened then close it before generating the report."); ReportingUIErrorWriter.process(ReportingUIErrorProcessor .getString("ERR_CODE_024"), new String[] { outputFileObj.getName() }); systemExit(FAILURE); } } /* 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") &amp;&amp; (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); } // Destroy the engine object. if (engine != null) { engine.destroy(); engine = null; } // Chemin A = C:/birt-runtime-2_0_1/Report Engine. Dans mon cas, j'ai // copier/coller le répertoire Report Engine dans mon répertoire lib où // je rassemble toutes mes } </code></pre> <p>I have pasted only relevant method code. Please help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload