Jump to content
JasperReports Library 7.0 is now available ×

Recommended Posts


I'm using Jasper Reports library on my application and iReport to design the reports.

The issue is the following:

I designed (first) a Half-letter sized report, then when calling and filling it on my application, JasperViewer shows it perfecly filled and sized as expected. However, if I sent it to print from there (JasperViewer) to a printer, it prints only half the contents, stretched to the edges. If I send to print to a PDF printer (Adobe PDF, PDFCreator), it generates the PDF correctly, with the expected size and orientation. Of course I can send to print from this PDF and everything goes peaches and gravy.

Furthermore, if I use the JasperExportManager and I export to PDF, it exports correctly too.

And finally, if instead of using the viewer, I sent directly to print using JasperPrintManager, it also prints stretched.

And by the way, just if you asked this to yourself, I mentioned early I 'first' created a Half-letter sized report and I got the described result. Well, I went forward and create another one, this time a letter sized one, and I still get the described result.


net.sf.jasperreports.engine.JasperReport jasperReport = (net.sf.jasperreports.engine.JasperReport) net.sf.jasperreports.engine.util.JRLoader.loadObject(getClass().getClassLoader().getResourceAsStream("recursos/reports/PurchaseSlip.jasper"));
java.util.Map parameters = new java.util.HashMap();
parameters.put("logo", new javax.swing.ImageIcon(getClass().getClassLoader().getResource("recursos/appitems/ERC_Logo_125x72.jpg")).getImage());
parameters.put("folioCompra", compra.getFolioCompra());
parameters.put("fechaRegistro", compra.getFechaRegistro().toString());
parameters.put("username", compra.getUsername());
parameters.put("nombreProveedor", proveedor.getNombreProveedor());
parameters.put("numeroDocumento", compra.getNumeroDocumento());
parameters.put("fechaMovimiento", compra.getFechaMovimiento().toString());
parameters.put("moneda", MONEDAS[java.lang.Integer.parseInt(compra.getMoneda()) - 1]);
parameters.put("condicionesPago", CONDICIONES_PAGO[java.lang.Integer.parseInt(compra.getCondicionesPago()) - 1]);
parameters.put("tasaCambio", tipoCambio.getTasaCambio());
parameters.put("comentario", compra.getComentario());
parameters.put("subtotal", compra.getSubtotal());
parameters.put("iva", compra.getIva());
parameters.put("descuento", compra.getDescuento());
parameters.put("total", compra.getTotal());
net.sf.jasperreports.engine.data.JRTableModelDataSource tableModelDataSource = new net.sf.jasperreports.engine.data.JRTableModelDataSource((DetalleCompraTableModel) tableDetalleCompra.getModel());
net.sf.jasperreports.engine.JasperPrint jasperPrint = net.sf.jasperreports.engine.JasperFillManager.fillReport(jasperReport, parameters, tableModelDataSource);
net.sf.jasperreports.engine.JasperExportManager.exportReportToPdfFile(jasperPrint, "PurchaseSlip.pdf");
net.sf.jasperreports.engine.JasperPrintManager.printReport(jasperPrint, true);
Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

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...