Ver Mensaje Individual
  #5 (permalink)  
Antiguo 06/04/2015, 14:47
marc85
 
Fecha de Ingreso: octubre-2014
Mensajes: 20
Antigüedad: 10 años, 1 mes
Puntos: 0
Respuesta: Reportes en pdf con guardado automático

Logré crear el archivo PDF con este código:

String urlreporte = "src/RptDxImagen.jasper";
String destino = "C:\\Reportes\\"+idserv+"\\"+idserv+".pdf";
//pdf(idpac, urlreporte, codpac);*/
try
{
Map parametros = new HashMap();
parametros.put("idserv", codserv);
JasperReport jasperReport=(JasperReport)JRLoader.loadObject(url reporte);
JasperPrint reporte = JasperFillManager.fillReport(urlreporte, parametros, con);
JRExporter exporter = new JRPdfExporter();
exporter.setParameter(JRExporterParameter.JASPER_P RINT, reporte);
exporter.setParameter(JRExporterParameter.OUTPUT_F ILE_NAME, destino);
exporter.exportReport();
//JasperExportManager.exportReportToPdfFile( reporte, destino);
//JOptionPane.showMessageDialog(null,"Diseñado");
}
catch(Exception e)
{
System.err.println( "Error iReport: " + e.getMessage() );
}

pero me crea un archivo vacío con este error que se genera en tiempo de ejecución:

Exception in thread "AWT-EventQueue-0" java.lang.NoSuchFieldError: PRINTSCALING
at net.sf.jasperreports.engine.export.JRPdfExporter.e xportReportToStream(JRPdfExporter.java:532)
at net.sf.jasperreports.engine.export.JRPdfExporter.e xportReportToStream(JRPdfExporter.java:532)
at net.sf.jasperreports.engine.export.JRPdfExporter.e xportReport(JRPdfExporter.java:417)
at Principal_Reportes.btnImagenActionPerformed(Princi pal_Reportes.java:301)
at Principal_Reportes.access$000(Principal_Reportes.j ava:22)
at Principal_Reportes$1.actionPerformed(Principal_Rep ortes.java:135)
at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.jav a:6516)
at javax.swing.JComponent.processMouseEvent(JComponen t.java:3321)
at java.awt.Component.processEvent(Component.java:628 1)
at java.awt.Container.processEvent(Container.java:222 9)
at java.awt.Component.dispatchEventImpl(Component.jav a:4872)
at java.awt.Container.dispatchEventImpl(Container.jav a:2287)
at java.awt.Component.dispatchEvent(Component.java:46 98)
at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4422)
at java.awt.Container.dispatchEventImpl(Container.jav a:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2719 )
at java.awt.Component.dispatchEvent(Component.java:46 98)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.j ava:740)
at java.awt.EventQueue.access$300(EventQueue.java:103 )
at java.awt.EventQueue$3.run(EventQueue.java:699)
at java.awt.EventQueue$3.run(EventQueue.java:697)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:713)
at java.awt.EventQueue$4.run(EventQueue.java:711)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 710)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:91)