urgent plz
Hi,
I'm developing a desktop application. there is a form generate reports for user and view it, but when I'm trying click "Export" button to save the report in myDocument i found it empty file except from a logo.
the same report saved in temporary file .pdf and contains all the data .. could anybody help me to fix it as i'm a beginner in JAVA?
this is the code of export reports :
publicvoid export(){
Properties m_ctx=Env.getCtx();
JFileChooser chooser =new JFileChooser();
chooser.setDialogType(JFileChooser.SAVE_DIALOG);
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
chooser.setDialogTitle(Msg.getMsg(Env.getCtx(),"Export"));
chooser.addChoosableFileFilter(new ExtensionFileFilter("pdf" ,Msg.getMsg(m_ctx,"FilePDF")));
if(chooser.showSaveDialog(this)!= JFileChooser.APPROVE_OPTION)
return;
File file = ExtensionFileFilter.getFile(chooser.getSelectedFile(), chooser.getFileFilter());
Viewer viewer =new Viewer();
try{
PDFGenerator.getPDFAsStream(new FileOutputStream(file),layoutEngine.getPageable(false));
file.createNewFile();
}catch(Exception e){
e.printStackTrace();
}
///////////////////////////
// saving the pdf in temp file
String name = file.getPath();
name = name.substring(name.lastIndexOf(".")+1).toLowerCase();
try{
if(name.equals("pdf")){
if(file==null)
file =File.createTempFile("temp",".pdf");
else
pdfViewer.getPDFAsStream(new FileOutputStream(file),layoutEngine.getPageable(false));
}
}catch(Exception e){
e.printStackTrace();
}

