Jump to content
JasperReports Library 7.0 is now available ×

defining a printer when printing jasper


2004 IR Help

Recommended Posts

By: viji - vijinarayanan

defining a printer when printing jasper

2005-07-19 01:02

if i click printer for jasper report,it prints on the server's default printer.it is possible to print the reports on the other network printer (client printers)?

 

if so,i had the program to list the printers in the server,but i don't know to pass the report to the client printer?help me to do this.

 

thanks in advance.

 

viji.

 

 

 

 

By: Dave G - dgarratt

RE: defining a printer when printing jasper

2005-07-19 11:44

I have a look at this code, it allows you to print to a nominated printer by name. However what I want to do is invoke the JasperViewer dialog and pass the default printer to that, but I don't know how to do that.

 

public static void run(String ReportName,Map parameters)

{

try

{

JasperReport jasperReport = (JasperReport) JRLoader.loadObjectFromLocation(ReportName+".jasper");

Connection conn = Common.selectedHost.db.conn;

JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn);

 

JRPrintServiceExporter exporter = new JRPrintServiceExporter();

exporter.setParameter( JRPrintServiceExporterParameter.JASPER_PRINT, jasperPrint);

PrintServiceAttributeSet serviceAttributeSet = new HashPrintServiceAttributeSet();

serviceAttributeSet.add(new PrinterName(JPrint.getPrinterShortName("My printer queue name",null));

exporter.setParameter( JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, serviceAttributeSet);

exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);

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

exporter.exportReport();

 

//JasperViewer.viewReport(jasperPrint,false);

 

}

catch (Exception e)

{

JOptionPane.showMessageDialog(null,e.getMessage(),"Error",JOptionPane.ERROR_MESSAGE);

}

}

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