I am using Report Engine 2.2.1 in Eclipse RCP Framework.
Currently I am trying to display report output in a SWT browser, in the case of HTML output format, the report is displayed correctly but in pdf the output text is something unrecognizable; While View report as pdf in Report Designer can display the same report correctly in pdf format.
Thanks in advace,
Zoha
PDF output is as follows:
%PDF-1.4 %âãÃÓ 3 0 obj <>stream xœÃ؉r£0 `÷ÞôÌîö¾¯=z·¼ÿõIjlÉ˒:žiH¬ï·ã¡ªÃ9ÇéÎnƒoë/ûÕà þà ~ý~_€æþ¢s&Qæè”wKF¾«›¶¿øê&ⲙï⦊¯Ä1Võ4¢˜*€0€¼º•êLˆ5Ÿ×õá%¯æ|è‹ ø’(¼`˜€&E(XöE@µ^lf[?æ æë|mü/;á‹ LüFýÉßÈØ×^}÷¿¼õj#éo û.Üמkߥ? ÿQ÷¢ŽoÀÚ§Æö±[¿Þøð‚-K¿ŠOÃ=ðç›Û³��ñÃ_¿Åõ*öÇÿ±Æ°#¾¾©T¦}Úv£Þ{$!߀…gÈû‡Ôõà 2"“¶ü)ßÃÂ…xHÊþTšÖ~ÈHêÑO�¼õP`"¦Ê‘ÃC« >šE@�}Ã…!>ò´•¤ó™kñ¤Yã´ÎŸÜ6=7ÞhÃä|ylx�ub3æå@Yè˜-@„¢gŠiÿ\šo¿jHúH*?køådò¥|¤´–�•n÷Ë@ _üÃ/á£eI>;À%ZTÇNjÚùWtž Q’ê³à É|y¿Ûð9~¢Ãg0öSÃ¥PÃ:ê¬6ü¤€’T¸Uó“5 _AúÕ;Â>Þo¶7*æÇ¯´tüÜÃôÿ´û[’³||™¥ûÙBþ‘/õP89üdÑ„ÿß?NìZ�÷¹Ó;óý»Ø§w.à O6ﻗ*Ã¥[u/ä¯d÷øù¼¹_âêÃò5Jœ>9UŠú]
.
.
.
.�K endstream endobj 2 0 obj<> endobj 8 0 obj<> endobj 18 0 obj<> endobj 19 0 obj<> endobj 20 0 obj<> endobj 21 0 obj<> endobj xref 0 22 0000000000 65535 f 0000008927 00000 n 0000029872 00000 n 0000029916 00000 n 0000029949 00000 n 0000030044 00000 n trailer <]/Info 21 0 R/Size 22>> startxref 30253 %%EOF
Java Code :
Calling the report from application-
view = (ReportPreviewerView) activePage.findView(ReportPreviewerView.ID);
view.previewReport(reportHome);
Preview the Report -
public void previewReport(String reportHome)
throws EngineException {
EngineConfig config = new EngineConfig();
// Create the report engine
config.setLogConfig("C:", Level.SEVERE);
IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
IReportEngine engine = factory.createReportEngine( config );
IReportRunnable design = null;
try {
// Open a report design -
// use design to
// modify design, retrieve
// embedded images etc.
String report;
report = reportHome;
//}
FileInputStream fs = new FileInputStream(report);
design = engine.openReportDesign(fs);
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
// Set Render context to handle url
// and image locations
HTMLRenderContext renderContext = new HTMLRenderContext();
[The type HTMLRenderContext is deprecated,
The local variable renderContext is never read]
//renderContext.setImageDirectory("c:/test/image");
HashMap< String, HTMLRenderContext >
contextMap = new HashMap< String, HTMLRenderContext >();
contextMap = config.getAppContext();
task.setAppContext(contextMap);
// Set rendering options -
// such as file or stream output,
// output format, whether it is
// embeddable, etc
// Render report to
// Byte Array
IRenderOption options;
options = new HTMLRenderOption( );
//FileOutputStream fop = new FileOutputStream();
ByteArrayOutputStream bos =new ByteArrayOutputStream();
options.setOutputStream(bos);
options.setOutputFormat(IRenderOption.OUTPUT_FORMAT_PDF);
//options.setOutputFormat(IRenderOption.OUTPUT_FORMAT_HTML);
task.setRenderOption(options);
// run the report and destroy the engine
task.run();
task.close();
//set Browser text accordingly
browser.setText(bos.toString());
engine.destroy();
} catch (Exception e) {
e.printStackTrace();
}
}
Attached File(s)
-
ReportCode.txt (2.28K)
Number of downloads: 3 -
ReportCode.txt (2.28K)
Number of downloads: 3



MultiQuote