dheerajsea123 Posted October 24, 2008 Share Posted October 24, 2008 Hi Everyone,I am quite new for jasper report, i have one report in rtf format when i use this in windows operating system it shows nicely,but when i generate this file through java in ubunto linux system, it doesn't show any thing in that but when i see the property of that file ,it shows complete size of data...so can any one have nay idea related to this problem pls suggest what i will do for that problem... thaks in advance.bye... Link to comment Share on other sites More sharing options...
ggalang Posted October 24, 2008 Share Posted October 24, 2008 are you having similar problem to this guy? http://www.linuxquestions.org/questions/linux-desktop-74/openoffice-and-rtf-560877/ Link to comment Share on other sites More sharing options...
dheerajsea123 Posted October 25, 2008 Author Share Posted October 25, 2008 Thanks for support. But this is not my problem. Actully i have one java file through which i generated jasper report in rtf format in windows system so that is worked perfectly, but when i genarate jasper report in linux through this class, file is open but there is no content show, but the size of file is same as in window file size, so suggest me where is the problem and how can i solve this problem.. Any Body Helpme... bye. Link to comment Share on other sites More sharing options...
lucianc Posted October 29, 2008 Share Posted October 29, 2008 Which RTF viewer are you using on Linux to open the file generated by JasperReports?Could you copy the Linux file to Windows and open it there? If it open correctly, than this is a problem with the Linux RTF viewer application.Regards,Lucian Link to comment Share on other sites More sharing options...
dheerajsea123 Posted October 30, 2008 Author Share Posted October 30, 2008 Thanks for reply,ya, i have checked it if i open that file in windows opearting system, it opens correctly and properly, i am sending my java code to you with attachment of java fiel so pls guide me properly where i require changes.thanks.below side define my java code.package WIL.Operations.Script.Utilities.JapserReport.Reports.Accounts.ClientBilling.BillRecent;////////PREDEFINED PACKAGE\\\\\\import java.util.*;import java.sql.*;import java.awt.event.*;import net.sf.jasperreports.view.JasperViewer;import net.sf.jasperreports.engine.xml.JRXmlLoader;import net.sf.jasperreports.engine.xml.*;import net.sf.jasperreports.engine.JasperCompileManager;import net.sf.jasperreports.engine.JasperFillManager;import net.sf.jasperreports.engine.JasperPrint;import net.sf.jasperreports.engine.design.JasperDesign;import net.sf.jasperreports.engine.JasperReport;import net.sf.jasperreports.engine.export.*;import net.sf.jasperreports.engine.export.JExcelApiExporter;import net.sf.jasperreports.engine.design.*;import net.sf.jasperreports.engine.*;import net.sf.jasperreports.engine.util.*;import net.sf.jasperreports.engine.design.JRAbstractClassCompiler;import net.sf.jasperreports.engine.design.JRAbstractCompiler;import net.sf.jasperreports.engine.design.JRDefaultCompiler;import net.sf.jasperreports.engine.JasperCompileManager;import net.sf.jasperreports.engine.design.JRClassCompiler.*;import net.sf.jasperreports.engine.design.JRCompiler.*;import net.sf.jasperreports.engine.design.JRMultiClassCompiler.*;import net.sf.jasperreports.engine.JasperManager;import net.sf.jasperreports.view.*;import org.apache.commons.collections.*;import org.apache.commons.digester.*;import org.apache.commons.beanutils.*;import java.lang.*;import com.lowagie.text.*;import java.io.*;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.io.OutputStream;import java.io.ByteArrayOutputStream;import javax.servlet.http.*;import javax.servlet.*;import java.text.*;import java.util.Date;///////USER DEFINED PACKAGE\\\\\import WIL.DBConn.ConnectionProvider;import WIL.GenericClasses.propertyreader.PropertyFileReader;public class BILLRECENT extends HttpServlet{ Connection con=null; ConnectionProvider provider; String str_WILInvoiceNo; String str_dollar,imgPath=""; Double db; String subFileRpt,subFPerson,subBillPerson; String fileName,fName; JasperDesign jasperDesign; JasperReport jasperReport; public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException { doPost(request,response); } public void doPost(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException { try { /////////// Flushing cache & set document content type \\\\\\\\ response.setHeader("Cache-Control", "no-cache"); response.setContentType("text/html"); //////////DATABASE CONNECTIVITY\\\\\\ provider=new ConnectionProvider(); con=provider.getConnection(); PropertyFileReader reader=new PropertyFileReader(); ///////// REQUEST FOR SESSION \\\\\\\ HttpSession session=request.getSession(); ////////// REQUESTED PARAMETER FROM BILLRECENT FORM \\\\\\\ str_WILInvoiceNo =(String)session.getAttribute("Invoice_No"); //str_dollar =(Double)session.getAttribute("dollar"); fName =request.getParameter("fName"); fileName =request.getParameter("filePath"); subFileRpt =request.getParameter("subFilePath"); subFPerson =request.getParameter("FPerson"); subBillPerson =request.getParameter("BillPerson"); str_dollar =request.getParameter("dollar"); db=Double.parseDouble(str_dollar); /////////// GETTING CONTEXT PATH FROM DD \\\\\\\\\ File file=new File(""); String sep=file.separator; String path=reader.readProperty("JRXML_Property","jrxmlproperty.properties","iReportPath",getServletContext(),"common"); //System.out.println(".jrxml File Path Before Using Replcae function ::"+fileName+"n"); fileName=fileName.replace("?",sep); subFileRpt=subFileRpt.replace("?",sep); subFPerson=subFPerson.replace("?",sep); subBillPerson=subBillPerson.replace("?",sep); //System.out.println(".jrxml File Path After Using Replcae function ::"+fileName+"n"); fileName=getServletContext().getRealPath(path).concat(fileName); subFileRpt=getServletContext().getRealPath(path).concat(subFileRpt); subFPerson=getServletContext().getRealPath(path).concat(subFPerson); subBillPerson=getServletContext().getRealPath(path).concat(subBillPerson); imgPath=reader.readProperty("JRXML_Property","jrxmlproperty.properties","imagePath",getServletContext(),"common"); imgPath=getServletContext().getRealPath(imgPath).concat(sep+"LoGo_Company.jpg"); //String path=getServletContext().getInitParameter("iReportPath"); //fileName =path+fileName; //subFileRpt =path+subFileRpt; //subFPerson =path+subFPerson; // subBillPerson =path+subBillPerson; //////////// CODE IS USED FOR DUBURGING PURPOSE \\\\\\\\\ System.out.println ("/////////////////////////////////////////////////////////////////"); System.out.println("Invoice No::"+str_WILInvoiceNo+"n"); System.out.println("dollar::"+str_dollar+"n"); System.out.println(".jrxml File Path ::"+fileName+"n"); System.out.println("SubReport File Path:"+subFileRpt+"n"); System.out.println("subFPerson File Path:"+subFPerson+"n"); System.out.println("subBillPerson File Path:"+subBillPerson+"n"); System.out.println("Image File Path:"+imgPath+"n"); System.out.println ("/////////////////////////////////////////////////////////////////"); //////////// PUTTING PARAMETER IN HASH MAP SAME AS USED IN JRXML FILES \\\\\\\ HashMap parameters = new HashMap(); parameters.put("InvoiceNo",str_WILInvoiceNo); parameters.put("DOLLAR",db); //System.out.println("***************************dollar*************************::"+db+"n"); parameters.put("SUBREPORT_DIR",subFileRpt); parameters.put("SUBREPORT_DIR_FPerson",subFPerson); parameters.put("SUBREPORT_DIR_BillPerson",subBillPerson); parameters.put("imgPath",imgPath); ////////// LOADING & COMPILING OUR SPECIFIED JRXML FILE \\\\\ jasperDesign=JRXmlLoader.load(fileName); jasperReport=JasperCompileManager.compileReport(jasperDesign); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,parameters,con); /* This Code Works For Open File In .DOC or RTF Format */ JRRtfExporter exporter = new JRRtfExporter(); response.setContentType("application/rtf"); response.setHeader("Content-Disposition", "inline; filename=""+str_WILInvoiceNo+".rtf""); OutputStream outputStream = response.getOutputStream(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputStream); exporter.exportReport(); outputStream.flush(); outputStream.close(); } catch(JRException jrex) { jrex.printStackTrace(); } catch (Exception j) { System.out.println("WILINVOICE_BILLRECENT_________Error:"+j.getMessage()); } finally { if(con!=null){ try { con.close(); con=null; provider.exitCon(); provider=null; fName=""; fileName=""; subFileRpt=""; subFPerson=""; subBillPerson=""; } catch(Exception er) { System.out.println("Connection Error in WILINVOICE_BILLRECENT_Error:"+er); } } }//CLOSING FIMNALLY }//CLOSING doPost METHOD }// CLOSING WILINVOICE_BILLRECENT CLASS Link to comment Share on other sites More sharing options...
lucianc Posted October 30, 2008 Share Posted October 30, 2008 Your code doesn't require any code changes.The issue is that the Linux RTF viewer is not able to render RTF documents generated by JasperReports. Try to use a different RTF viewer application (btw, you haven't answered my question on which viewer you are using).Regards,Lucian Link to comment Share on other sites More sharing options...
dheerajsea123 Posted November 5, 2008 Author Share Posted November 5, 2008 thanks for support,Sorry i was not there that's why i am not replying you...still i faced same problem and you were asked, what RTF Viewer i am using, so I used ooWriter viewer for RTF format in my ubuntoo linux system..pls help me out.waiting for ur reply. Link to comment Share on other sites More sharing options...
lucianc Posted November 5, 2008 Share Posted November 5, 2008 Try another viewer, for instance AbiWord.Regards,Lucian Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now