Jump to content

Unable to print to names printer


Recommended Posts

By: omegared - shamiakira

Unable to print to names printer

2006-04-28 06:14

Hi

 

I know this topic has come up before but I couldn't find the answer in your replies.

 

I am writing a java collection with a template as follows:

JasperFillManager.fillReportToFile("src/template.jasper", null, new JRBeanCollectionDataSource©);

 

I then try to specify a named printer to print to as is shown in the print service example:

 

PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();

printRequestAttributeSet.add(MediaSizeName.ISO_A4);

 

PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();

 

printServiceAttributeSet.add(new PrinterName("HP LaserJet 4100 - PT03362", Locale.getDefault()));

 

 

JRPrintServiceExporter exporter = new JRPrintServiceExporter();

 

exporter.setParameter(JRExporterParameter.INPUT_FILE_NAME, "src/template.jrprint");

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();

 

Unfortunately I get a 'no suitable print service found exception'. If I comment out the line: printServiceAttributeSet.add(new PrinterName("HP LaserJet 4100 - PT03362", Locale.getDefault())); i get the dialogue listing 3 networked printers which I select and print to. Does anybody know why I am unable to specify the printer I want e.g. HP LaserJet 4100 - PT03362. Printer names are listed in the dialogue as:

"\dc-met-profileHP laserJet 4100-PT03362

\dc-met-profileKonika....etc

 

Can somebody please advise me what I may be doing wrong.

 

 

 

 

 

By: omegared - shamiakira

RE: Unable to print to names printer

2006-05-02 03:41

oops. wasn't including the full path which requirs the network name "\dc-met...".

 

cheers

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