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();

}

[2882 byte] By [Amiraa] at [2007-11-27 8:42:11]
# 1

PDFGenerator.getPDFAsStream(new FileOutputStream(file),layoutEngine.getPageable(false));

file.createNewFile();

Just turn around those two lines of code. Even if are new to java you should see that you are at first generating the report and then replacing it with a new empty file ;-) it should be the outher way around.

florianfa at 2007-7-12 20:41:27 > top of Java-index,Desktop,Core GUI APIs...