Jump to content
We've recently updated our Privacy Statement, available here ×

Empty pdf file (0 kb) when exporting report to PDF as a stand-alone application


land-of-mordor

Recommended Posts

 I'm coding an application using Netbeans as IDE to deal and interchange data between an Access database and a PBX software that uses firebird. Everything was fine until I reached the reports issue.

Working in Netbeans IDE everything worked really fine. Report is created and converted to the file type I wanted (rtf, odt, pdf...), but when a take the content of the "dist" folder (where the compiled application is stored by Netbeans with all the needed libraries) and execute the application, the report is created sucessfully but when it try to save it as PDF file, the only output is a empty (0 kb occupied) PDF file. I tried with other file types, like rtf and odt, and the application works great in both situations, runned using Netbeans IDE and as a stand-alone application.

Is there an specific library or reference that is loaded in Netbeans IDE but not imported when compiled as a stand-alone application? may be is another silly thing? any help or thoughts?

Thanks.

Code:
//IMPORT SECTIONpackage contactosagenda;import java.awt.Cursor;import java.awt.Desktop;import java.io.File;import java.util.logging.Level;import java.util.logging.Logger;import javax.swing.ImageIcon;import javax.swing.JOptionPane;import javax.swing.UIManager;import javax.swing.plaf.DesktopPaneUI;import net.sf.jasperreports.engine.*;import net.sf.jasperreports.engine.export.JRPdfExporter;import net.sf.jasperreports.engine.util.JRLoader;import net.sf.jasperreports.engine.export.oasis.JROdtExporter;//REPORT LAUNCHERprivate void lanzaInforme(Clientes listado){        try {                            JasperReport informe = (JasperReport)JRLoader.loadObject(new File(System.getProperties().getProperty("user.dir") + System.getProperty("file.separator")+"reportClientes.jasper"));                                JRDataSource j = listado.getReportDataSource();                        JasperPrint reportPrint = JasperFillManager.fillReport(informe,null,j);                         //JRExporter export = new JRPdfExporter();            //JRExporter export = new JRRtfExporter();            JRExporter export = new JROdtExporter();            export.setParameter(JRExporterParameter.JASPER_PRINT, reportPrint);            String ruta = System.getProperties().getProperty("user.dir") + System.getProperty("file.separator") + "temp.odt";            //File f = File(ruta);            export.setParameter(JRExporterParameter.OUTPUT_FILE, new File(ruta));                        export.exportReport();                        //Desktop.getDesktop().open(new File(ruta));            //JOptionPane.showMessageDialog(this.getParent(),"El archivo debe estar en\n" + f.getPath());                        } catch (Exception ex) {            JOptionPane.showMessageDialog(this.getParent(), "Se ha producido el siguiente error:\n" + ex);            Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);                    }    }
Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Thanks for replying!!

 

I think my problem it's not related with the issue you saying. I'm not using any web-related stuff, just a simply application to be run on a desktop. So I think the Adobe version I've installed in the PC won't be the cause. But this afternoon I'll update Adobe Reader and see what happend.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...