nlasystems Posted February 15, 2013 Share Posted February 15, 2013 Hi AllWe have been using JasperReports for more than 7 years now and this is the first time this happenned.We have 2 printers on the same server, namely an HP LaserJet P1005 and an HP Deskjet 2510 series. From the same application, printing to the LaserJet is OK but printing to the Deskjet produces a strange result. The fonts expand horizontally and as a result, the right hand half the page gets truncated horizontally.The first thing we did was upgrade to the latest version (5.0.1) but exactly the same behaviour persisted.If we export the report to a PDF, both printers print OK from Acrobat Reader. That is why we now think that the problem is with the JRPrintServiceExporter*******I have also uploaded a pdf to show how the report should look like and a jpg scan of the wrong print-out. *******We have captured the PrintServices Attributes which we are listing below.Found print service: Win32 Printer : \SERVER-PCHP LaserJet P1005 job-name - Java Printing requesting-user-name - USER copies-supported - null spool-data-destination - file:/R:/nlaPayroll/out.prn orientation-requested - portrait page-ranges - 1-2147483647 media - iso-a4 media-printable-area - (3.725,3.556)->(202.523,289.899)mm ipp-attribute-fidelity - false sheet-collate - uncollated sun-alternate-media - null chromaticity - color printer-resolution - 60000x60000 dphi Found print service: Win32 Printer : \SERVER-PCHP Deskjet 2510 series job-name - Java Printing requesting-user-name - USER copies-supported - null spool-data-destination - file:/R:/nlaPayroll/out.prn orientation-requested - portrait page-ranges - 1-2147483647 media - iso-a4 media-printable-area - (3.133,3.133)->(203.708,290.576)mm ipp-attribute-fidelity - false sheet-collate - collated sun-alternate-media - null chromaticity - color printer-resolution - 60000x30000 dphi This is the method we are using to print: - public void print(String printerName) throws Exception { try { Copies noOfCopies = new Copies(1); PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet(); printRequestAttributeSet.add(MediaSizeName.ISO_A4); printRequestAttributeSet.add(noOfCopies); PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet(); JRPrintServiceExporter exporter = new JRPrintServiceExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, printRequestAttributeSet); exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, printServiceAttributeSet); if (printerName==null) exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, true); else { exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, false); printServiceAttributeSet.add(new PrinterName(printerName, null)); } exporter.exportReport(); if (printerName==null) lastPrinterUsed=exporter.getPrintService().getName();; } catch (Exception e) { System.out.println("Docbuilder.print() error> "+e); throw e; } } Link to comment Share on other sites More sharing options...
nlasystems Posted March 5, 2013 Author Share Posted March 5, 2013 I have now uploaded two pictures to further clarify my issue.Thanks Link to comment Share on other sites More sharing options...
oscar.gutierrez Posted June 18, 2013 Share Posted June 18, 2013 I have exactly the same problem, I'm using HP Deskjet 2510 series printer. Until now I didn't find solve.Tell me if you found it please. Link to comment Share on other sites More sharing options...
nlasystems Posted June 19, 2013 Author Share Posted June 19, 2013 Sorry but we didn't find a solution to this. We gave up on it actually. Link to comment Share on other sites More sharing options...
sunal Posted January 13, 2014 Share Posted January 13, 2014 I had the same problem and this works for me:PrintRequestAttributeSet printRequestAttrs = new HashPrintRequestAttributeSet();printRequestAttrs.add(new PrinterResolution(600, 600, ResolutionSyntax.DPI)); // this resolution solved the problemJRPrintServiceExporter exporter = new JRPrintServiceExporter();exporter.setParameter(JRExporterParameter.JASPER_PRINT, report);exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, printRequestAttrs);exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.TRUE);exporter.exportReport(); Link to comment Share on other sites More sharing options...
nlasystems Posted January 17, 2014 Author Share Posted January 17, 2014 Bingo!Thanks Sunal! It worked for us too.The only thing we need to amend now is to prompt printer setup BEFORE your exporting code because we will use this code for this exception only.Incidentally we encountered another printer with the same problem (HP Deskjet 1050) In this case 600DPI made matters worse but 300 DPI woked just fine.Thanks again. Link to comment Share on other sites More sharing options...
nlasystems Posted February 6, 2014 Author Share Posted February 6, 2014 GRRR!!! Actually it did not work, It worked for the HP Deskjet 1050 as stated above.When I posted wictory I assumed that since it worked for the 1050 it is going to work for 2515 but sorry to say that it persistently kept printing half a page horizontally. We tried both 300 and 600 dpi. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now