Jump to content
Changes to the Jaspersoft community edition download ×

How to Print Lanscape Report

Recommended Posts

By: Oleg - oleg_vn

How to Print Lanscape Report

2002-12-17 05:25

My code:


PrintService[] services = PrinterJob.lookupPrintServices();


for (int i = 0; i < services.length; i++) {






PageRanges pRanges= new PageRanges("2,4,6");


try {

PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();



if (jasperPrint.getOrientation() == JRReport.ORIENTATION_LANDSCAPE) {

printRequestAttributeSet.add( OrientationRequested.LANDSCAPE );

} else {

printRequestAttributeSet.add( OrientationRequested.PORTRAIT );



PrintServiceAttributeSet printServiceAttributeSet =



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.FALSE);





catch (JRException ex)




catch (Exception ex)






All fine, but printed only part of page. (Left margin = 80.75 cm)

I`m added this :



new MediaPrintableArea(



(float)jasperPrint.getPageWidth() / 72f,

(float)jasperPrint.getPageHeight() / 72f,

MediaPrintableArea.INCH )


and catch Exception :

"No suitable print service found."


Help me!







By: Claudio Pi - claudiopi

RE: How to Print Lanscape Report

2003-09-11 12:28

I'm having the exact same problem trying to set the printer margins without the print dialog box: I'm getting the Exception: "No suitable print service found.".


I notice you are setting the MediaPrintableArea (in the JRPrintServiceExporter) after you get the PrintService array. If I try executing the exact same code before getting the services I got services.length==0 and then the exception is thrown !!


Any solution or workaround for this problem ?


Thanks in advance,


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