BIRT & gzip problem? [message #646337] |
Thu, 23 December 2010 07:03  |
Eclipse User |
|
|
|
Hello,
I continue my old discussion
http://www.eclipse.org/forums/index.php?t=msg&th=200471& amp;start=0&S=ae0a82523ba358e5ca8bd169eb4ad907
As Jason wrote the BIRT uses allways the iText setFullCompression method. I found out that for my big test material the winzip compress the BIRT pdf to the 5% size.
So I tried to use the GZIPOutputStream for my servlet. My servlet processed the gzip file, but I couldn't open the unzipped file with the Adobe reader.
So I wrote the simple java program, which runs simple BIRT report with the simple data. I run the program and used gunzip. I got the error message "There was an error opening this document. Access denied" when I tried to open the file with the Adobe reader. This error message sound like I don't have rights to open the file, but file is only read-only.
It is possible that this problem is not related on the BIRT, but is there some problem with my Java program?
Thanks,
Mika
GzipRunReport.java:
import java.io.File;
import java.io.FileOutputStream;
import java.util.zip.GZIPOutputStream;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.HTMLRenderOption;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
import org.eclipse.birt.report.engine.api.ReportEngine;
public class GzipRunReport {
public static void main(String[] args) throws Exception {
GZIPOutputStream gzipOutputStream = null;
ReportEngine engine = null;
try {
String templateFilename = "C:\\birtWorkspace\\BirtEsittely\\reports\\simple.rptdesign";
//String templateFilename = "C:\\testiRapo.rptdesign";
EngineConfig config = new EngineConfig();
config
.setEngineHome("C:\\birt-runtime-2_6_1\\ReportEngine");
// Create the report engine.
engine = new ReportEngine(config);
IReportRunnable report = null;
// Create the report
report = engine.openReportDesign(templateFilename);
// Create the task
IRunAndRenderTask task = engine.createRunAndRenderTask(report);
// Set the options
HTMLRenderOption options = new HTMLRenderOption();
options.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_PDF);
File file = new File("c:\\birtWork\\birt.pdf.gz");
FileOutputStream fileOutputStream = new FileOutputStream(file);
gzipOutputStream = new GZIPOutputStream(fileOutputStream);
options.setOutputStream(gzipOutputStream);
task.setRenderOption(options);
task.run();
} finally {
// Destroy the report engine.
gzipOutputStream.close();
engine.destroy();
Platform.shutdown();
}
}
}
parameters.xml:
<?xml version="1.0" encoding="UTF-8"?>
<parameters>
<data>This is an important report.</data>
</parameters>
simple.rptdesign:
<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.22" id="1">
<property name="createdBy">Eclipse BIRT Designer Version 2.6.1.v20100902 Build <2.6.1.v20100915-1750></property>
<property name="units">in</property>
<property name="iconFile">/templates/blank_report.gif</property>
<property name="bidiLayoutOrientation">ltr</property>
<property name="imageDPI">96</property>
<data-sources>
<oda-data-source extensionID="org.eclipse.datatools.enablement.oda.xml" name="Data Source" id="7">
<property name="FILELIST">C:\birtWorkspace\BirtEsittely\reports\parameters.xml</property>
</oda-data-source>
</data-sources>
<data-sets>
<oda-data-set extensionID="org.eclipse.datatools.enablement.oda.xml.dataSet" name="Data Set" id="8">
<list-property name="columnHints">
<structure>
<property name="columnName">data</property>
<text-property name="heading">data</text-property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">data</property>
<property name="dataType">string</property>
</structure>
</list-property>
</structure>
<property name="dataSource">Data Source</property>
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">data</property>
<property name="nativeName">data</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
</list-property>
<xml-property name="queryText"><![CDATA[table0#-TNAME-#table0#:#[/parameters]#:#{data;STRING;/data}]]></xml-property>
<xml-property name="designerValues"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<model:DesignValues xmlns:design="http://www.eclipse.org/datatools/connectivity/oda/design" xmlns:model="http://www.eclipse.org/birt/report/model/adapter/odaModel">
<Version>1.0</Version>
<design:ResultSets derivedMetaData="true">
<design:resultSetDefinitions>
<design:resultSetColumns>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>data</design:name>
<design:position>1</design:position>
<design:nativeDataTypeCode>12</design:nativeDataTypeCode>
<design:precision>-1</design:precision>
<design:scale>-1</design:scale>
<design:nullability>Unknown</design:nullability>
</design:attributes>
<design:usageHints>
<design:label>data</design:label>
<design:formattingHints/>
</design:usageHints>
</design:resultColumnDefinitions>
</design:resultSetColumns>
<design:criteria/>
</design:resultSetDefinitions>
</design:ResultSets>
</model:DesignValues>
]]></xml-property>
<list-property name="privateDriverProperties">
<ex-property>
<name>MAX_ROW</name>
<value>-1</value>
</ex-property>
<ex-property>
<name>XML_FILE</name>
</ex-property>
</list-property>
</oda-data-set>
</data-sets>
<styles>
<style name="report" id="4">
<property name="fontFamily">sans-serif</property>
<property name="fontSize">10pt</property>
</style>
<style name="crosstab" id="5">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
<style name="crosstab-cell" id="6">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
</styles>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<!--
<property name="backgroundImage">reports/draft.jpg</property>
-->
<page-footer>
<text id="3">
<property name="contentType">html</property>
<text-property name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
</text>
</page-footer>
</simple-master-page>
</page-setup>
<body>
<data id="9">
<property name="whiteSpace">nowrap</property>
<property name="dataSet">Data Set</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">data</property>
<text-property name="displayName">data</text-property>
<expression name="expression" type="javascript">dataSetRow["data"]</expression>
<property name="dataType">string</property>
</structure>
</list-property>
<property name="resultSetColumn">data</property>
</data>
</body>
</report>
|
|
|
|
|
|
|
|
Re: BIRT & gzip problem? [message #647100 is a reply to message #647027] |
Tue, 04 January 2011 10:33  |
Eclipse User |
|
|
|
Mika,
Sure. If you get time in the future this would be cool.
Jason
On 1/4/2011 1:57 AM, Mika wrote:
> Jason,
>
> It is possible that I write later this to the birt exchange dev share.
> Currently I'm too busy with project...
>
> BR,
>
> Mika
|
|
|
Powered by
FUDForum. Page generated in 0.32050 seconds