Jump to content

Landscape Printing and MediaPrintableArea


2005 IR Help

Recommended Posts

By: darineG228 - darineg228

Landscape Printing and MediaPrintableArea

2004-12-28 05:19

I am trying to print a report in landscape. When I export it in pdf, it looks fine, and when I use "JasperPrintManager.printReport(jasperPrint,false);"

the print result is ok on the default printer.

But I would like to be able to specify the printer and I tried this code :

PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet(); printRequestAttributeSet.add(MediaSizeName.ISO_A4);

PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();

printRequestAttributeSet.add(OrientationRequested.LANDSCAPE);

printRequestAttributeSet.add(new MediaPrintableArea(4.572f, 4.572f, 200f, 288.205f, MediaPrintableArea.MM));

printServiceAttributeSet.add(new PrinterName("HP LaserJet 1200", null));

 

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); exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG,Boolean.FALSE);

exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.TRUE);

exporter.exportReport();

 

 

If I don't add any MediaPrintableArea object into the

printRequestAttributeSet, the page is printed in lanscape but the left part is cut.

Reading lots of information in this forum, I understood I should add a MediaPrintableArea object specifying characteristics of the printer as I am using french printer. But I now get the exception "net.sf.jasperreports.engine.JRException: No suitable print service found"

 

I guess I am not so far from the solution, but I didn't find it. Please if anyone get an idea or at least can show me the already existing answer in this forum I didn't see....

 

Thanks.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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