Jump to content
Changes to the Jaspersoft community edition download ×

Problems printing directly to a printer


Recommended Posts

By: Peter Walleri - prwalleri

Problems printing directly to a printer

2003-04-29 04:37

When I try to print using localhost on the web server I have no problems printing to a printer. The printer dialog box pops up and I can select the printer I need.

 

The problem I have is when I try to do the same thing from a work station. I do not get my report printed and I do not get the printer dialog box.

 

Can someone help me?

 

Here is the code fragment:

 

JasperReport jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath());

 

Map parameters = new HashMap();

//parameters.put("ReportTitle", "Address Report");

parameters.put("BaseDir", reportFile.getParentFile());

 

JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, new JRResultSetDataSource(rs));

 

PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();

switch(paperSize) {

case 1: {

printRequestAttributeSet.add(MediaSizeName.NA_LETTER);

break;

}

case 2: {

printRequestAttributeSet.add(MediaSizeName.NA_LEGAL);

break;

}

default: {

printRequestAttributeSet.add(MediaSizeName.NA_LETTER);

break;

}

}

 

PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();

//printServiceAttributeSet.add(new PrinterName("HP LaserJet 5000 Series PCL", null));

//printServiceAttributeSet.add(new PrinterName("Auto HP LaserJet 5000 Series PCL on ADMIN", 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();

 

Thanks

Peter

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