Skip to Main Content

Java and JavaScript in the Database

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java Print API shows different job name on the printer than in the spooling queue

KishoreUgamrajSep 20 2013

Hi,

   I am using Java print API (javax.print package) to send a bunch of documents for printing. Below is the code section that I am using to print documents through java program. When the document is sent for printing, I see the Job name is created properly in the print spooling queue on windows machine. But, when i go to the actual printer, the job name is different on the printer than what i saw in spooling. Since I am printing 100s of documents in batch, it gets very difficult to identify which document did not print, in case of issues.

  I also used the java.awt.print package . The java.awt.print.PrinterJob has a method setJobName(String). When i used this package, I got the name appear properly in both places. But I wish to use javax.print with the document name appear on printer queue.

  public void printDocument(File pDoc, PrintService pService, DocFlavor pFlavor)

    throws Exception

  {

    logMessage(true, "Printing Doc::" + pDoc.getAbsolutePath());

    FileInputStream is = new FileInputStream(pDoc);

    // Create the print job

    DocPrintJob job = pService.createPrintJob();

    //Set print request attributes with file name as job name

    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();

    aset.add(new JobName(pDoc.getName(), Locale.getDefault()));

    //Create the DocAttributeSet  with document name

    DocAttributeSet dset = new HashDocAttributeSet();

   dset.add(new DocumentName(pDoc.getName(), Locale.getDefault()));

   

  //Create a Doc object to be printed and add DocAttributeSet to it.

    Doc doc = new SimpleDoc(is, pFlavor, dset);

    job.print(doc, aset);

    is.close();

    logMessage(true, "Done printing Doc::" + pDoc.getAbsolutePath());

  }

What i see on Windows machine Print queue:

DocumentName     Status     Owner      Page Size

502_79_93858.pdf   Printing  imgadmin  1

502_80_93859.pdf                imgadmin  1

What I see on the job status in actual printer ( and i tried different printers, all of them have same issue):

Job ID   Job Name        Job Owner Copies

RIP598  dfA2431heidi2     lp             1

RIP599  dfA2431heidi2     lp             1

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 18 2013
Added on Sep 20 2013
0 comments
2,240 views