Jump to content

Recommended Posts

Posted

Hello,

Is there a way you can specify a paper type in a Jasper Report (or java).
Example:  label, plain, envelope, ...

 

Thanks in advance

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted

 Hi,

Yes, please take look at this class  MediaSize for more details. You can customize your media size as you want or you can use standard ISO sizes. i hope the following code could help you. :)

JasperDesign jasperDesign = JRXmlLoader.load(filename.jrxml);
   

JasperReport jasRep = JasperCompileManager.compileReport(jasperDesign);

JasperPrint jasPrnt = JasperFillManager.fillReport(jasRep, null ,con);

PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();

MediaSizeName mediaSizeName = MediaSize.ISO.A4.getMediaSizeName();


printRequestAttributeSet.add(mediaSizeName);


JRPrintServiceExporter exporter = new JRPrintServiceExporter();

exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);


exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET,
       printRequestAttributeSet);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG,
     Boolean.FALSE);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG,
     Boolean.FALSE);
   
exporter.exportReport();



Post Edited by rshekhar2000 at 04/09/2010 09:02



Post Edited by rshekhar2000 at 04/09/2010 09:03

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